Package org.apache.cxf.helpers
Class IOUtils
- java.lang.Object
- 
- org.apache.cxf.helpers.IOUtils
 
- 
 public final class IOUtils extends Object 
- 
- 
Field SummaryFields Modifier and Type Field Description static intDEFAULT_BUFFER_SIZEstatic CharsetUTF8_CHARSET
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static voidconsume(InputStream in)static voidconsume(InputStream input, int atLeast)Consumes at least the given number of bytes from the input streamstatic intcopy(InputStream input, OutputStream output)static intcopy(InputStream input, OutputStream output, int bufferSize)static voidcopy(Reader input, Writer output, int bufferSize)static intcopyAndCloseInput(InputStream input, OutputStream output)static intcopyAndCloseInput(InputStream input, OutputStream output, int bufferSize)static voidcopyAndCloseInput(Reader input, Writer output)static voidcopyAndCloseInput(Reader input, Writer output, int bufferSize)static voidcopyAtLeast(InputStream input, OutputStream output, int atLeast)Copy at least the specified number of bytes from the input to the output or until the inputstream is finished.static voidcopyAtLeast(Reader input, Writer output, int atLeast)static booleanisEmpty(InputStream is)static ByteArrayInputStreamloadIntoBAIS(InputStream in)Load the InputStream into memory and return a ByteArrayInputStream that represents it.static StringnewStringFromBytes(byte[] bytes)Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.static StringnewStringFromBytes(byte[] bytes, int start, int length)Use this function instead of new String(byte[], int, int) to avoid surprises from non-standard default encodings.static StringnewStringFromBytes(byte[] bytes, String charsetName)Use this function instead of new String(byte[], String) to avoid surprises from non-standard default encodings.static StringnewStringFromBytes(byte[] bytes, String charsetName, int start, int length)Use this function instead of new String(byte[], int, int, String) to avoid surprises from non-standard default encodings.static InputStreamnullOrNotEmptyStream(InputStream is)Checks if input stream is empty.static byte[]readBytesFromStream(InputStream in)static StringreadStringFromStream(InputStream in)static StringtoString(InputStream input)static StringtoString(InputStream input, int bufferSize)static StringtoString(InputStream input, int bufferSize, String charset)static StringtoString(InputStream input, String charset)static StringtoString(Reader input)static StringtoString(Reader input, int bufSize)static voidtransferTo(InputStream inputStream, File destinationFile)
 
- 
- 
- 
Field Detail- 
UTF8_CHARSETpublic static final Charset UTF8_CHARSET 
 - 
DEFAULT_BUFFER_SIZEpublic static final int DEFAULT_BUFFER_SIZE - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
nullOrNotEmptyStreampublic static InputStream nullOrNotEmptyStream(InputStream is) throws IOException Checks if input stream is empty. If the standard InputStream means do not provide such details, the stream might be wrapped into PushbackInputStream and is going to be returned instead of original one.- Parameters:
- is- input stream to check
- Returns:
- "null" if original input stream is empty, otherwise original stream or original stream wrapped into PushbackInputStream.
- Throws:
- IOException
 
 - 
isEmptypublic static boolean isEmpty(InputStream is) throws IOException - Throws:
- IOException
 
 - 
newStringFromBytespublic static String newStringFromBytes(byte[] bytes, String charsetName) Use this function instead of new String(byte[], String) to avoid surprises from non-standard default encodings.- Parameters:
- bytes-
- charsetName-
 
 - 
newStringFromBytespublic static String newStringFromBytes(byte[] bytes) Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.- Parameters:
- bytes-
 
 - 
newStringFromBytespublic static String newStringFromBytes(byte[] bytes, String charsetName, int start, int length) Use this function instead of new String(byte[], int, int, String) to avoid surprises from non-standard default encodings.- Parameters:
- bytes-
- charsetName-
- start-
- length-
 
 - 
newStringFromBytespublic static String newStringFromBytes(byte[] bytes, int start, int length) Use this function instead of new String(byte[], int, int) to avoid surprises from non-standard default encodings.- Parameters:
- bytes-
- start-
- length-
 
 - 
copypublic static int copy(InputStream input, OutputStream output) throws IOException - Throws:
- IOException
 
 - 
copyAndCloseInputpublic static int copyAndCloseInput(InputStream input, OutputStream output) throws IOException - Throws:
- IOException
 
 - 
copyAndCloseInputpublic static int copyAndCloseInput(InputStream input, OutputStream output, int bufferSize) throws IOException - Throws:
- IOException
 
 - 
copyAndCloseInputpublic static void copyAndCloseInput(Reader input, Writer output) throws IOException - Throws:
- IOException
 
 - 
copyAndCloseInputpublic static void copyAndCloseInput(Reader input, Writer output, int bufferSize) throws IOException - Throws:
- IOException
 
 - 
copypublic static int copy(InputStream input, OutputStream output, int bufferSize) throws IOException - Throws:
- IOException
 
 - 
copyAtLeastpublic static void copyAtLeast(InputStream input, OutputStream output, int atLeast) throws IOException Copy at least the specified number of bytes from the input to the output or until the inputstream is finished.- Parameters:
- input-
- output-
- atLeast-
- Throws:
- IOException
 
 - 
copyAtLeastpublic static void copyAtLeast(Reader input, Writer output, int atLeast) throws IOException - Throws:
- IOException
 
 - 
copypublic static void copy(Reader input, Writer output, int bufferSize) throws IOException - Throws:
- IOException
 
 - 
transferTopublic static void transferTo(InputStream inputStream, File destinationFile) throws IOException - Throws:
- IOException
 
 - 
toStringpublic static String toString(InputStream input) throws IOException - Throws:
- IOException
 
 - 
toStringpublic static String toString(InputStream input, String charset) throws IOException - Throws:
- IOException
 
 - 
toStringpublic static String toString(InputStream input, int bufferSize) throws IOException - Throws:
- IOException
 
 - 
toStringpublic static String toString(InputStream input, int bufferSize, String charset) throws IOException - Throws:
- IOException
 
 - 
toStringpublic static String toString(Reader input) throws IOException - Throws:
- IOException
 
 - 
toStringpublic static String toString(Reader input, int bufSize) throws IOException - Throws:
- IOException
 
 - 
readStringFromStreampublic static String readStringFromStream(InputStream in) throws IOException - Throws:
- IOException
 
 - 
loadIntoBAISpublic static ByteArrayInputStream loadIntoBAIS(InputStream in) throws IOException Load the InputStream into memory and return a ByteArrayInputStream that represents it. Closes the in stream.- Parameters:
- in-
- Throws:
- IOException
 
 - 
consumepublic static void consume(InputStream in) throws IOException - Throws:
- IOException
 
 - 
consumepublic static void consume(InputStream input, int atLeast) throws IOException Consumes at least the given number of bytes from the input stream- Parameters:
- input-
- atLeast-
- Throws:
- IOException
 
 - 
readBytesFromStreampublic static byte[] readBytesFromStream(InputStream in) throws IOException - Throws:
- IOException
 
 
- 
 
-