Class IOUtils
java.lang.Object
net.adoptopenjdk.icedteaweb.io.IOUtils
Copied from RICO (https://github.com/rico-projects/rico)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopy(InputStream inputStream, OutputStream outputStream) Copies the content of an input stream to an output stream.static voidcopy(InputStream inputStream, OutputStream outputStream, int bufferSize) Copies the content of an input stream to an output stream.static byte[]fromBase64(String content) Converts a Base64 string into a byte array.static byte[]fromBase64StripWhitespace(String content) Converts a Base64 string into a byte array.static byte[]readContent(InputStream inputStream) Reads the content of an input stream into a byte array.static StringreadContentAsString(InputStream inputStream, Charset encoding) Reads the content of an input stream into a string.static StringreadContentAsUtf8String(InputStream inputStream) Reads the content of an input stream into a string using UTF-8 encoding.static StringtoBase64(byte[] bytes) Converts a byte array into a Base64 string.static StringtoBase64splitIntoMultipleLines(byte[] bytes, int maxCharsPerLine) Converts a byte array into a Base64 string.static voidwriteContent(OutputStream outputStream, byte[] rawData) static voidwriteUtf8Content(OutputStream outputStream, String content)
-
Constructor Details
-
IOUtils
public IOUtils()
-
-
Method Details
-
toBase64
Converts a byte array into a Base64 string.- Parameters:
bytes- the bytes to convert- Returns:
- the Base64 representation of the input bytes.
-
toBase64splitIntoMultipleLines
Converts a byte array into a Base64 string. The output string is split into multiple lines such that all but the last line have a given length.- Parameters:
bytes- the bytes to convertmaxCharsPerLine- the max num of chars per line- Returns:
- the Base64 representation of the input bytes.
-
fromBase64
Converts a Base64 string into a byte array.- Parameters:
content- the Base64 string- Returns:
- the byte array representation of the input string.
-
fromBase64StripWhitespace
Converts a Base64 string into a byte array. Additionally strips all white spaces from the input.- Parameters:
content- the Base64 string- Returns:
- the byte array representation of the input string.
-
copy
Copies the content of an input stream to an output stream.- Parameters:
inputStream- the source to read fromoutputStream- the target to write to- Throws:
IOException- if reading from or writing to the streams failed
-
copy
public static void copy(InputStream inputStream, OutputStream outputStream, int bufferSize) throws IOException Copies the content of an input stream to an output stream.- Parameters:
inputStream- the source to read fromoutputStream- the target to write tobufferSize- the size of the buffer to allocate for copying- Throws:
IOException- if reading from or writing to the streams failed
-
readContent
Reads the content of an input stream into a byte array.- Parameters:
inputStream- the stream to read from- Returns:
- array of bytes read from the stream
- Throws:
IOException- if reading from the stream failed
-
readContentAsUtf8String
Reads the content of an input stream into a string using UTF-8 encoding.- Parameters:
inputStream- the stream to read from- Returns:
- string read from the stream
- Throws:
IOException- if reading from the stream failed
-
readContentAsString
public static String readContentAsString(InputStream inputStream, Charset encoding) throws IOException Reads the content of an input stream into a string.- Parameters:
inputStream- the stream to read fromencoding- the character set to use when converting the bytes to characters- Returns:
- string read from the stream
- Throws:
IOException- if reading from the stream failed
-
writeUtf8Content
- Throws:
IOException
-
writeContent
- Throws:
IOException
-