/** * Copies the contents of the given {@link InputStream} * to the given {@link OutputStream}. Shortcut for * <pre> * copy(pInputStream, pOutputStream, new byte[8192]); * </pre> * @param pInputStream The input stream, which is being read. * It is guaranteed, that {@link InputStream#close()} is called * on the stream. * @param pOutputStream The output stream, to which data should * be written. May be null, in which case the input streams * contents are simply discarded. * @param pClose True guarantees, that {@link OutputStream#close()} * is called on the stream. False indicates, that only * {@link OutputStream#flush()} should be called finally. * * @return Number of bytes, which have been copied. * @throws IOException An I/O error occurred. */ public static long copy(InputStream pInputStream, OutputStream pOutputStream, boolean pClose) throws IOException { return copy(pInputStream, pOutputStream, pClose, new byte[DEFAULT_BUFFER_SIZE]); }
/** * Copies the contents of the given {@link InputStream} * to the given {@link OutputStream}. Shortcut for * <pre> * copy(pInputStream, pOutputStream, new byte[8192]); * </pre> * * @param pInputStream The input stream, which is being read. * It is guaranteed, that {@link InputStream#close()} is called * on the stream. * @param pOutputStream The output stream, to which data should * be written. May be null, in which case the input streams * contents are simply discarded. * @param pClose True guarantees, that {@link OutputStream#close()} * is called on the stream. False indicates, that only * {@link OutputStream#flush()} should be called finally. * * @return Number of bytes, which have been copied. * @throws IOException An I/O error occurred. */ public static long copy(InputStream pInputStream, OutputStream pOutputStream, boolean pClose) throws IOException { return copy(pInputStream, pOutputStream, pClose, new byte[DEFAULT_BUFFER_SIZE]); }
/** * Copies the contents of the given {@link InputStream} * to the given {@link OutputStream}. Shortcut for * <pre> * copy(pInputStream, pOutputStream, new byte[8192]); * </pre> * * @param inputStream The input stream, which is being read. * It is guaranteed, that {@link InputStream#close()} is called * on the stream. * @param outputStream The output stream, to which data should * be written. May be null, in which case the input streams * contents are simply discarded. * @param closeOutputStream True guarantees, that {@link OutputStream#close()} * is called on the stream. False indicates, that only * {@link OutputStream#flush()} should be called finally. * * @return Number of bytes, which have been copied. * @throws IOException An I/O error occurred. */ public static long copy(InputStream inputStream, OutputStream outputStream, boolean closeOutputStream) throws IOException { return copy(inputStream, outputStream, closeOutputStream, new byte[DEFAULT_BUFFER_SIZE]); }
/** * This convenience method allows to read a * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s * content into a string. The platform's default character encoding * is used for converting bytes into characters. * @param pStream The input stream to read. * @see #asString(InputStream, String) * @return The streams contents, as a string. * @throws IOException An I/O error occurred. */ public static String asString(InputStream pStream) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(pStream, baos, true); return baos.toString(); }
/** * This convenience method allows to read a * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s * content into a string. The platform's default character encoding * is used for converting bytes into characters. * @param pStream The input stream to read. * @see #asString(InputStream, String) * @return The streams contents, as a string. * @throws IOException An I/O error occurred. */ public static String asString(InputStream pStream) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(pStream, baos, true); return baos.toString(); }
/** * This convenience method allows to read a * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s * content into a string. The platform's default character encoding * is used for converting bytes into characters. * * @param pStream The input stream to read. * @see #asString(InputStream, String) * @return The streams contents, as a string. * @throws IOException An I/O error occurred. */ public static String asString(InputStream pStream) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(pStream, baos, true); return baos.toString(); }
/** * This convenience method allows to read a * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s * content into a string. The platform's default character encoding * is used for converting bytes into characters. * @param pStream The input stream to read. * @see #asString(InputStream, String) * @return The streams contents, as a string. * @throws IOException An I/O error occurred. */ public static String asString(InputStream pStream) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(pStream, baos, true); return baos.toString(); }
/** * This convenience method allows to read a * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s * content into a string, using the given character encoding. * * @param pStream The input stream to read. * @param pEncoding The character encoding, typically "UTF-8". * @see #asString(InputStream) * @return The streams contents, as a string. * @throws IOException An I/O error occurred. */ public static String asString(InputStream pStream, String pEncoding) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(pStream, baos, true); return baos.toString(pEncoding); }
/** * This convenience method allows to read a * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s * content into a string, using the given character encoding. * @param pStream The input stream to read. * @param pEncoding The character encoding, typically "UTF-8". * @see #asString(InputStream) * @return The streams contents, as a string. * @throws IOException An I/O error occurred. */ public static String asString(InputStream pStream, String pEncoding) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(pStream, baos, true); return baos.toString(pEncoding); }
/** * This convenience method allows to read a * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s * content into a string. The platform's default character encoding * is used for converting bytes into characters. * * @param inputStream The input stream to read. * @see #asString(InputStream, String) * @return The streams contents, as a string. * @throws IOException An I/O error occurred. */ public static String asString(InputStream inputStream) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(inputStream, baos, true); return baos.toString(); }
/** * This convenience method allows to read a * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s * content into a string, using the given character encoding. * @param pStream The input stream to read. * @param pEncoding The character encoding, typically "UTF-8". * @see #asString(InputStream) * @return The streams contents, as a string. * @throws IOException An I/O error occurred. */ public static String asString(InputStream pStream, String pEncoding) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(pStream, baos, true); return baos.toString(pEncoding); }
/** * This convenience method allows to read a * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s * content into a string, using the given character encoding. * @param pStream The input stream to read. * @param pEncoding The character encoding, typically "UTF-8". * @see #asString(InputStream) * @return The streams contents, as a string. * @throws IOException An I/O error occurred. */ public static String asString(InputStream pStream, String pEncoding) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(pStream, baos, true); return baos.toString(pEncoding); }
/** * This convenience method allows to read a * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s * content into a string. The platform's default character encoding * is used for converting bytes into characters. * * @param pStream The input stream to read. * @see #asString(InputStream, String) * @return The streams contents, as a string. * @throws IOException An I/O error occurred. */ public static String asString(InputStream pStream) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(pStream, baos, true); return baos.toString(); }
/** * This convenience method allows to read a * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s * content into a string, using the given character encoding. * * @param inputStream The input stream to read. * @param encoding The character encoding, typically "UTF-8". * @see #asString(InputStream) * @return The streams contents, as a string. * @throws IOException An I/O error occurred. */ public static String asString(InputStream inputStream, String encoding) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(inputStream, baos, true); return baos.toString(encoding); }
/** * This convenience method allows to read a * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s * content into a string, using the given character encoding. * * @param pStream The input stream to read. * @param pEncoding The character encoding, typically "UTF-8". * @see #asString(InputStream) * @return The streams contents, as a string. * @throws IOException An I/O error occurred. */ public static String asString(InputStream pStream, String pEncoding) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(pStream, baos, true); return baos.toString(pEncoding); }
/** * <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); }
/** * <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 }
/** * <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); }
/** * <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); }
/** * <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); }