Package org.apache.wicket.util.io
Class Streams
- java.lang.Object
-
- org.apache.wicket.util.io.Streams
-
public final class Streams extends java.lang.ObjectUtilities methods for working with input and output streams.- Author:
- Jonathan Locke, Igor Vaynberg
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcopy(java.io.InputStream in, java.io.OutputStream out)Writes the input stream to the output stream.static intcopy(java.io.InputStream in, java.io.OutputStream out, int bufSize)Writes the input stream to the output stream.static intcopyAndClose(java.io.InputStream in, java.io.OutputStream out)Writes the input stream to the output stream.static voidloadFromXml(java.util.Properties properties, java.io.InputStream inputStream)Loads properties from an XML input stream into the provided properties object.static java.io.InputStreamreadNonCaching(java.net.URL url)Sets the connection to a URL as non-caching and returns the input stream.static java.lang.StringreadString(java.io.InputStream in)Reads a stream as a string.static java.lang.StringreadString(java.io.InputStream in, java.lang.CharSequence encoding)Reads a string using a character encoding.static java.lang.StringreadString(java.io.Reader in)Reads all input from a reader into a string.
-
-
-
Method Detail
-
copyAndClose
public static int copyAndClose(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOExceptionWrites the input stream to the output stream. Input is done without a Reader object, meaning that the input is copied in its raw form. After it is copied it will close the streams.- Parameters:
in- The input streamout- The output stream- Returns:
- Number of bytes copied from one stream to the other
- Throws:
java.io.IOException
-
copy
public static int copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOExceptionWrites the input stream to the output stream. Input is done without a Reader object, meaning that the input is copied in its raw form.- Parameters:
in- The input streamout- The output stream- Returns:
- Number of bytes copied from one stream to the other
- Throws:
java.io.IOException
-
copy
public static int copy(java.io.InputStream in, java.io.OutputStream out, int bufSize) throws java.io.IOExceptionWrites the input stream to the output stream. Input is done without a Reader object, meaning that the input is copied in its raw form.- Parameters:
in- The input streamout- The output streambufSize- The buffer size. A good value is 4096.- Returns:
- Number of bytes copied from one stream to the other
- Throws:
java.io.IOException
-
loadFromXml
public static void loadFromXml(java.util.Properties properties, java.io.InputStream inputStream) throws java.io.IOExceptionLoads properties from an XML input stream into the provided properties object.- Parameters:
properties- The object to load the properties intoinputStream-- Throws:
java.io.IOException- When the input stream could not be read from
-
readNonCaching
public static java.io.InputStream readNonCaching(java.net.URL url) throws java.io.IOExceptionSets the connection to a URL as non-caching and returns the input stream.- Parameters:
url- the url to read from- Returns:
- the input stream for this url
- Throws:
java.io.IOException- when a connection cannot be opened
-
readString
public static java.lang.String readString(java.io.InputStream in) throws java.io.IOExceptionReads a stream as a string.- Parameters:
in- The input stream- Returns:
- The string
- Throws:
java.io.IOException
-
readString
public static java.lang.String readString(java.io.InputStream in, java.lang.CharSequence encoding) throws java.io.IOExceptionReads a string using a character encoding.- Parameters:
in- The inputencoding- The character encoding of the input data- Returns:
- The string
- Throws:
java.io.IOException
-
readString
public static java.lang.String readString(java.io.Reader in) throws java.io.IOExceptionReads all input from a reader into a string.- Parameters:
in- The input- Returns:
- The string
- Throws:
java.io.IOException
-
-