Tabnine Logo
StreamResource$Builder.contents
Code IndexAdd Tabnine to your IDE (free)

How to use
contents
method
in
org.apache.juneau.http.StreamResource$Builder

Best Java code snippets using org.apache.juneau.http.StreamResource$Builder.contents (Showing top 11 results out of 315)

origin: apache/juneau

@RestMethod
public StreamResource a05() throws Exception {
  return StreamResource.create().contents(new ByteArrayInputStream("foo".getBytes())).build();
}
origin: apache/juneau

return (T)StreamResource.create().headers(headers).mediaType(mediaType).contents(getInputStream()).build();
origin: org.apache.juneau/juneau-rest-client

return (T)StreamResource.create().headers(headers).mediaType(mediaType).contents(getInputStream()).build();
origin: apache/juneau

return (T)StreamResource.create().headers(headers).mediaType(mediaType).contents(getInputStream()).build();
origin: apache/juneau

/**
 * Returns an instance of a {@link StreamResource} that represents the contents of a resource binary file from the
 * classpath.
 *
 * <h5 class='section'>See Also:</h5>
 * <ul>
 *     <li class='jf'>{@link org.apache.juneau.rest.RestContext#REST_classpathResourceFinder}
 *     <li class='jm'>{@link org.apache.juneau.rest.RestRequest#getClasspathStreamResource(String)}
 * </ul>
 *
 * @param name The name of the resource (i.e. the value normally passed to {@link Class#getResourceAsStream(String)}.
 * @param mediaType The value to set as the <js>"Content-Type"</js> header for this object.
 * @param cached If <jk>true</jk>, the resource will be read into a byte array for fast serialization.
 * @return A new stream resource, or <jk>null</jk> if resource could not be found.
 * @throws IOException
 */
@SuppressWarnings("resource")
public StreamResource getClasspathStreamResource(String name, MediaType mediaType, boolean cached) throws IOException {
  InputStream is = context.getClasspathResource(name, getLocale());
  if (is == null)
    return null;
  StreamResource.Builder b = StreamResource.create().mediaType(mediaType).contents(is);
  if (cached)
    b.cached();
  return b.build();
}
origin: org.apache.juneau/juneau-rest-server

/**
 * Returns an instance of a {@link StreamResource} that represents the contents of a resource binary file from the
 * classpath.
 *
 * <h5 class='section'>See Also:</h5>
 * <ul>
 *     <li class='jf'>{@link org.apache.juneau.rest.RestContext#REST_classpathResourceFinder}
 *     <li class='jm'>{@link org.apache.juneau.rest.RestRequest#getClasspathStreamResource(String)}
 * </ul>
 *
 * @param name The name of the resource (i.e. the value normally passed to {@link Class#getResourceAsStream(String)}.
 * @param mediaType The value to set as the <js>"Content-Type"</js> header for this object.
 * @param cached If <jk>true</jk>, the resource will be read into a byte array for fast serialization.
 * @return A new stream resource, or <jk>null</jk> if resource could not be found.
 * @throws IOException
 */
@SuppressWarnings("resource")
public StreamResource getClasspathStreamResource(String name, MediaType mediaType, boolean cached) throws IOException {
  InputStream is = context.getClasspathResource(name, getLocale());
  if (is == null)
    return null;
  StreamResource.Builder b = StreamResource.create().mediaType(mediaType).contents(is);
  if (cached)
    b.cached();
  return b.build();
}
origin: apache/juneau

/**
 * Returns an instance of a {@link StreamResource} that represents the contents of a resource binary file from the
 * classpath.
 *
 * <h5 class='section'>See Also:</h5>
 * <ul>
 *     <li class='jf'>{@link org.apache.juneau.rest.RestContext#REST_classpathResourceFinder}
 *     <li class='jm'>{@link org.apache.juneau.rest.RestRequest#getClasspathStreamResource(String)}
 * </ul>
 *
 * @param name The name of the resource (i.e. the value normally passed to {@link Class#getResourceAsStream(String)}.
 * @param mediaType The value to set as the <js>"Content-Type"</js> header for this object.
 * @param cached If <jk>true</jk>, the resource will be read into a byte array for fast serialization.
 * @return A new stream resource, or <jk>null</jk> if resource could not be found.
 * @throws IOException
 */
@SuppressWarnings("resource")
public StreamResource getClasspathStreamResource(String name, MediaType mediaType, boolean cached) throws IOException {
  InputStream is = context.getClasspathResource(name, getLocale());
  if (is == null)
    return null;
  StreamResource.Builder b = StreamResource.create().mediaType(mediaType).contents(is);
  if (cached)
    b.cached();
  return b.build();
}
origin: apache/juneau

@RestMethod
public StreamResource a06() throws Exception {
  return StreamResource.create().contents(new StringReader("foo")).build();
}
origin: apache/juneau

@RestMethod
public StreamResource a04() throws Exception {
  return StreamResource.create().contents("foo".getBytes()).build();
}
origin: apache/juneau

@RestMethod
public StreamResource a01() throws Exception {
  return StreamResource.create().contents("foo").build();
}
origin: apache/juneau

  @RestMethod
  public StreamResource a07() throws Exception {
    return StreamResource.create().contents(new StringBuilder("foo")).build();
  }
}
org.apache.juneau.httpStreamResource$Buildercontents

Javadoc

Specifies the contents for this resource.

This method can be called multiple times to add more content.

Popular methods of StreamResource$Builder

  • build
    Create a new StreamResource using values in this builder.
  • mediaType
    Specifies the resource media type string.
  • <init>
  • cached
    Specifies that this resource is intended to be cached. This will trigger the contents to be loaded i
  • headers
    Specifies HTTP response header values.
  • header
    Specifies an HTTP response header value.

Popular in Java

  • Reading from database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • addToBackStack (FragmentTransaction)
  • setContentView (Activity)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now