Java Code Examples for org.apache.tomcat.util.http.fileupload.util.Streams#copy()

The following examples show how to use org.apache.tomcat.util.http.fileupload.util.Streams#copy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultipartStream.java    From Tomcat8-Source-Read with MIT License 2 votes vote down vote up
/**
 * <p>Reads <code>body-data</code> from the current
 * <code>encapsulation</code> and writes its contents into the
 * output <code>Stream</code>.
 *
 * <p>Arbitrary large amounts of data can be processed by this
 * method using a constant size buffer. (see {@link
 * #MultipartStream(InputStream,byte[],int,
 *   MultipartStream.ProgressNotifier) constructor}).
 *
 * @param output The <code>Stream</code> to write data into. May
 *               be null, in which case this method is equivalent
 *               to {@link #discardBodyData()}.
 *
 * @return the amount of data written.
 *
 * @throws MalformedStreamException if the stream ends unexpectedly.
 * @throws IOException              if an i/o error occurs.
 */
public int readBodyData(OutputStream output)
        throws MalformedStreamException, IOException {
    return (int) Streams.copy(newInputStream(), output, false); // N.B. Streams.copy closes the input stream
}
 
Example 2
Source File: MultipartStream.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * <p>Reads <code>body-data</code> from the current
 * <code>encapsulation</code> and writes its contents into the
 * output <code>Stream</code>.
 *
 * <p>Arbitrary large amounts of data can be processed by this
 * method using a constant size buffer. (see {@link
 * #MultipartStream(InputStream,byte[],int,
 *   MultipartStream.ProgressNotifier) constructor}).
 *
 * @param output The <code>Stream</code> to write data into. May
 *               be null, in which case this method is equivalent
 *               to {@link #discardBodyData()}.
 *
 * @return the amount of data written.
 *
 * @throws MalformedStreamException if the stream ends unexpectedly.
 * @throws IOException              if an i/o error occurs.
 */
public int readBodyData(OutputStream output)
        throws MalformedStreamException, IOException {
    final InputStream istream = newInputStream();
    return (int) Streams.copy(istream, output, false);
}
 
Example 3
Source File: MultipartStream.java    From tomcatsrc with Apache License 2.0 2 votes vote down vote up
/**
 * <p>Reads <code>body-data</code> from the current
 * <code>encapsulation</code> and writes its contents into the
 * output <code>Stream</code>.
 *
 * <p>Arbitrary large amounts of data can be processed by this
 * method using a constant size buffer. (see {@link
 * #MultipartStream(InputStream,byte[],int,
 *   MultipartStream.ProgressNotifier) constructor}).
 *
 * @param output The <code>Stream</code> to write data into. May
 *               be null, in which case this method is equivalent
 *               to {@link #discardBodyData()}.
 *
 * @return the amount of data written.
 *
 * @throws MalformedStreamException if the stream ends unexpectedly.
 * @throws IOException              if an i/o error occurs.
 */
public int readBodyData(OutputStream output)
        throws MalformedStreamException, IOException {
    return (int) Streams.copy(newInputStream(), output, false); // N.B. Streams.copy closes the input stream
}