Package org.apache.cxf.helpers
Class IOUtils
java.lang.Object
org.apache.cxf.helpers.IOUtils
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
consume
(InputStream in) static void
consume
(InputStream input, int atLeast) Consumes at least the given number of bytes from the input streamstatic int
copy
(InputStream input, OutputStream output) static int
copy
(InputStream input, OutputStream output, int bufferSize) static void
static int
copyAndCloseInput
(InputStream input, OutputStream output) static int
copyAndCloseInput
(InputStream input, OutputStream output, int bufferSize) static void
copyAndCloseInput
(Reader input, Writer output) static void
copyAndCloseInput
(Reader input, Writer output, int bufferSize) static void
copyAtLeast
(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 void
copyAtLeast
(Reader input, Writer output, int atLeast) static boolean
isEmpty
(InputStream is) static ByteArrayInputStream
Load the InputStream into memory and return a ByteArrayInputStream that represents it.static String
newStringFromBytes
(byte[] bytes) Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.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.static String
newStringFromBytes
(byte[] bytes, String charsetName) Use this function instead of new String(byte[], String) to avoid surprises from non-standard default encodings.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.static InputStream
Checks if input stream is empty.static byte[]
static String
static String
toString
(InputStream input) static String
toString
(InputStream input, int bufferSize) static String
toString
(InputStream input, int bufferSize, String charset) static String
toString
(InputStream input, String charset) static String
static String
static void
transferTo
(InputStream inputStream, File destinationFile)
-
Field Details
-
UTF8_CHARSET
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
-
Method Details
-
nullOrNotEmptyStream
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
-
isEmpty
- Throws:
IOException
-
newStringFromBytes
Use this function instead of new String(byte[], String) to avoid surprises from non-standard default encodings.- Parameters:
bytes
-charsetName
-
-
newStringFromBytes
Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.- Parameters:
bytes
-
-
newStringFromBytes
Use this function instead of new String(byte[], int, int, String) to avoid surprises from non-standard default encodings.- Parameters:
bytes
-charsetName
-start
-length
-
-
newStringFromBytes
Use this function instead of new String(byte[], int, int) to avoid surprises from non-standard default encodings.- Parameters:
bytes
-start
-length
-
-
copy
- Throws:
IOException
-
copyAndCloseInput
- Throws:
IOException
-
copyAndCloseInput
public static int copyAndCloseInput(InputStream input, OutputStream output, int bufferSize) throws IOException - Throws:
IOException
-
copyAndCloseInput
- Throws:
IOException
-
copyAndCloseInput
public static void copyAndCloseInput(Reader input, Writer output, int bufferSize) throws IOException - Throws:
IOException
-
copy
- Throws:
IOException
-
copyAtLeast
public 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
-
copyAtLeast
- Throws:
IOException
-
copy
- Throws:
IOException
-
transferTo
- Throws:
IOException
-
toString
- Throws:
IOException
-
toString
- Throws:
IOException
-
toString
- Throws:
IOException
-
toString
- Throws:
IOException
-
toString
- Throws:
IOException
-
toString
- Throws:
IOException
-
readStringFromStream
- Throws:
IOException
-
loadIntoBAIS
Load the InputStream into memory and return a ByteArrayInputStream that represents it. Closes the in stream.- Parameters:
in
-- Throws:
IOException
-
consume
- Throws:
IOException
-
consume
Consumes at least the given number of bytes from the input stream- Parameters:
input
-atLeast
-- Throws:
IOException
-
readBytesFromStream
- Throws:
IOException
-