@Immutable public final class StreamHelper extends Object
null aware, where on writing an output stream may
never be null.| Modifier and Type | Method and Description |
|---|---|
static InputStream |
checkForInvalidFilterInputStream(InputStream aIS) |
static ESuccess |
close(AutoCloseable aCloseable)
Close the passed stream by encapsulating the declared
IOException. |
static ESuccess |
closeWithoutFlush(AutoCloseable aCloseable)
Close the passed object, without trying to call flush on it.
|
static ESuccess |
copyInputStreamToOutputStream(InputStream aIS,
OutputStream aOS)
Pass the content of the given input stream to the given output stream.
|
static ESuccess |
copyInputStreamToOutputStream(InputStream aIS,
OutputStream aOS,
byte[] aBuffer)
Pass the content of the given input stream to the given output stream.
|
static ESuccess |
copyInputStreamToOutputStream(InputStream aIS,
OutputStream aOS,
byte[] aBuffer,
MutableLong aCopyByteCount)
Pass the content of the given input stream to the given output stream.
|
static ESuccess |
copyInputStreamToOutputStream(InputStream aIS,
OutputStream aOS,
byte[] aBuffer,
MutableLong aCopyByteCount,
Long aLimit)
Pass the content of the given input stream to the given output stream.
|
static ESuccess |
copyInputStreamToOutputStream(InputStream aIS,
OutputStream aOS,
MutableLong aCopyByteCount)
Pass the content of the given input stream to the given output stream.
|
static ESuccess |
copyInputStreamToOutputStreamAndCloseOS(InputStream aIS,
OutputStream aOS)
Pass the content of the given input stream to the given output stream.
|
static ESuccess |
copyInputStreamToOutputStreamWithLimit(InputStream aIS,
OutputStream aOS,
long nLimit)
Pass the content of the given input stream to the given output stream.
|
static ESuccess |
copyInputStreamToOutputStreamWithLimitAndCloseOS(InputStream aIS,
OutputStream aOS,
long nLimit)
Pass the content of the given input stream to the given output stream.
|
static ESuccess |
copyReaderToWriter(Reader aReader,
Writer aWriter)
Pass the content of the given reader to the given writer.
|
static ESuccess |
copyReaderToWriter(Reader aReader,
Writer aWriter,
char[] aBuffer)
Pass the content of the given reader to the given writer.
|
static ESuccess |
copyReaderToWriter(Reader aReader,
Writer aWriter,
char[] aBuffer,
MutableLong aCopyCharCount)
Pass the content of the given reader to the given writer.
|
static ESuccess |
copyReaderToWriter(Reader aReader,
Writer aWriter,
char[] aBuffer,
MutableLong aCopyCharCount,
Long aLimit)
Pass the content of the given reader to the given writer.
|
static ESuccess |
copyReaderToWriter(Reader aReader,
Writer aWriter,
MutableLong aCopyCharCount)
Pass the content of the given reader to the given writer.
|
static ESuccess |
copyReaderToWriterAndCloseWriter(Reader aReader,
Writer aWriter)
Pass the content of the given reader to the given writer.
|
static ESuccess |
copyReaderToWriterWithLimit(Reader aReader,
Writer aWriter,
long nLimit)
Pass the content of the given reader to the given writer.
|
static ESuccess |
copyReaderToWriterWithLimitAndCloseWriter(Reader aReader,
Writer aWriter,
long nLimit)
Pass the content of the given reader to the given writer.
|
static NonBlockingStringReader |
createReader(char[] aChars) |
static InputStreamReader |
createReader(InputStream aIS,
Charset aCharset) |
static NonBlockingStringReader |
createReader(String sText) |
static OutputStreamWriter |
createWriter(OutputStream aOS,
Charset aCharset) |
static ESuccess |
flush(Flushable aFlushable)
Flush the passed object encapsulating the declared
IOException. |
static byte[] |
getAllBytes(IHasInputStream aISP)
Read all bytes from the passed input stream into a byte array.
|
static byte[] |
getAllBytes(InputStream aIS)
Read all bytes from the passed input stream into a byte array.
|
static String |
getAllBytesAsString(IHasInputStream aISP,
Charset aCharset)
Read all bytes from the passed input stream into a string.
|
static String |
getAllBytesAsString(InputStream aIS,
Charset aCharset)
Read all bytes from the passed input stream into a string.
|
static char[] |
getAllCharacters(Reader aReader)
Read all characters from the passed reader into a char array.
|
static String |
getAllCharactersAsString(Reader aReader)
Read all characters from the passed reader into a String.
|
static int |
getAvailable(InputStream aIS)
Get the number of available bytes in the passed input stream.
|
static InputStream |
getBuffered(InputStream aIS) |
static OutputStream |
getBuffered(OutputStream aOS) |
static Reader |
getBuffered(Reader aReader) |
static Writer |
getBuffered(Writer aWriter) |
static NonBlockingByteArrayOutputStream |
getCopy(InputStream aIS)
Get a byte buffer with all the available content of the passed input
stream.
|
static NonBlockingStringWriter |
getCopy(Reader aReader) |
static NonBlockingByteArrayOutputStream |
getCopyWithLimit(InputStream aIS,
long nLimit)
Get a byte buffer with all the available content of the passed input
stream.
|
static NonBlockingStringWriter |
getCopyWithLimit(Reader aReader,
long nLimit) |
static boolean |
isBuffered(InputStream aIS) |
static boolean |
isBuffered(OutputStream aOS) |
static boolean |
isBuffered(Reader aReader) |
static boolean |
isBuffered(Writer aWriter) |
static boolean |
isKnownEOFException(Class<?> aClass)
Check if the passed class is a known EOF exception class.
|
static boolean |
isKnownEOFException(Throwable t)
Check if the passed exception is a known EOF exception.
|
static int |
readFully(InputStream aIS,
byte[] aBuffer)
Read the whole buffer from the input stream.
|
static int |
readFully(InputStream aIS,
byte[] aBuffer,
int nOfs,
int nLen)
Read the whole buffer from the input stream.
|
static String |
readSafeUTF(DataInput aDIS)
Because
DataOutputStream.writeUTF(String) has a limit of 64KB this
methods provides a similar solution for reading like
DataInputStream.readUTF() but what was written in
writeSafeUTF(DataOutput, String). |
static ICommonsList<String> |
readStreamLines(IHasInputStream aISP,
Charset aCharset)
Get the content of the passed Spring resource as one big string in the
passed character set.
|
static ICommonsList<String> |
readStreamLines(IHasInputStream aISP,
Charset aCharset,
int nLinesToSkip,
int nLinesToRead)
Get the content of the passed Spring resource as one big string in the
passed character set.
|
static ICommonsList<String> |
readStreamLines(InputStream aIS,
Charset aCharset)
Get the content of the passed stream as a list of lines in the passed
character set.
|
static void |
readStreamLines(InputStream aIS,
Charset aCharset,
Consumer<String> aLineCallback)
Read the complete content of the passed stream and pass each line
separately to the passed callback.
|
static ICommonsList<String> |
readStreamLines(InputStream aIS,
Charset aCharset,
int nLinesToSkip,
int nLinesToRead)
Get the content of the passed stream as a list of lines in the passed
character set.
|
static void |
readStreamLines(InputStream aIS,
Charset aCharset,
int nLinesToSkip,
int nLinesToRead,
Consumer<String> aLineCallback)
Read the content of the passed stream line by line and invoking a callback
on all matching lines.
|
static void |
readStreamLines(InputStream aIS,
Charset aCharset,
List<String> aTargetList)
Get the content of the passed stream as a list of lines in the passed
character set.
|
static void |
skipFully(InputStream aIS,
long nBytesToSkip)
Fully skip the passed amounts in the input stream.
|
static void |
writeSafeUTF(DataOutput aDOS,
String s)
Because
DataOutputStream.writeUTF(String) has a limit of 64KB this
methods provides a similar solution but simply writing the bytes. |
static ESuccess |
writeStream(OutputStream aOS,
byte[] aBuf)
Write bytes to an
OutputStream. |
static ESuccess |
writeStream(OutputStream aOS,
byte[] aBuf,
int nOfs,
int nLen)
Write bytes to an
OutputStream. |
static ESuccess |
writeStream(OutputStream aOS,
String sContent,
Charset aCharset)
Write bytes to an
OutputStream. |
public static boolean isKnownEOFException(@Nullable Throwable t)
t - The throwable/exception to be checked. May be null.true if it is a user-created EOF exceptionpublic static boolean isKnownEOFException(@Nullable Class<?> aClass)
aClass - The class to be checked. May be null.true if it is a known EOF exception class.@Nonnull public static ESuccess closeWithoutFlush(@Nullable @WillClose AutoCloseable aCloseable)
aCloseable - The object to be closed. May be null.ESuccess.SUCCESS if the object was successfully closed.@Nonnull public static ESuccess close(@Nullable @WillClose AutoCloseable aCloseable)
IOException.
If the passed object also implements the Flushable interface, it is
tried to be flushed before it is closed.aCloseable - The object to be closed. May be null.ESuccess if the object was successfully closed.@Nonnull public static ESuccess flush(@Nullable Flushable aFlushable)
IOException.aFlushable - The flushable to be flushed. May be null.ESuccess.SUCCESS if the object was successfully flushed.@Nonnull public static ESuccess copyInputStreamToOutputStreamAndCloseOS(@WillClose @Nullable InputStream aIS, @WillClose @Nullable OutputStream aOS)
aIS - The input stream to read from. May be null.
Automatically closed!aOS - The output stream to write to. May be null.
Automatically closed!ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyInputStreamToOutputStreamWithLimitAndCloseOS(@WillClose @Nullable InputStream aIS, @WillClose @Nullable OutputStream aOS, @Nonnegative long nLimit)
aIS - The input stream to read from. May be null.
Automatically closed!aOS - The output stream to write to. May be null.
Automatically closed!nLimit - The maximum number of bytes to be copied to the output stream. Must
be ≥ 0.ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyInputStreamToOutputStream(@WillClose @Nullable InputStream aIS, @WillNotClose @Nullable OutputStream aOS)
aIS - The input stream to read from. May be null.
Automatically closed!aOS - The output stream to write to. May be null. Not
automatically closed!ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyInputStreamToOutputStream(@WillClose @Nullable InputStream aIS, @WillNotClose @Nullable OutputStream aOS, @Nullable MutableLong aCopyByteCount)
aIS - The input stream to read from. May be null.
Automatically closed!aOS - The output stream to write to. May be null. Not
automatically closed!aCopyByteCount - An optional mutable long object that will receive the total number
of copied bytes. Note: and optional old value is overwritten!ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyInputStreamToOutputStreamWithLimit(@WillClose @Nullable InputStream aIS, @WillNotClose @Nullable OutputStream aOS, @Nonnegative long nLimit)
aIS - The input stream to read from. May be null.
Automatically closed!aOS - The output stream to write to. May be null. Not
automatically closed!nLimit - The maximum number of bytes to be copied to the output stream. Must
be ≥ 0.ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyInputStreamToOutputStream(@WillClose @Nullable InputStream aIS, @WillNotClose @Nullable OutputStream aOS, @Nonnull byte[] aBuffer)
aIS - The input stream to read from. May be null.
Automatically closed!aOS - The output stream to write to. May be null. Not
automatically closed!aBuffer - The buffer to use. May not be null.ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyInputStreamToOutputStream(@WillClose @Nullable InputStream aIS, @WillNotClose @Nullable OutputStream aOS, @Nonnull @Nonempty byte[] aBuffer, @Nullable MutableLong aCopyByteCount)
aIS - The input stream to read from. May be null.
Automatically closed!aOS - The output stream to write to. May be null. Not
automatically closed!aBuffer - The buffer to use. May not be null.aCopyByteCount - An optional mutable long object that will receive the total number
of copied bytes. Note: and optional old value is overwritten!ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyInputStreamToOutputStream(@WillClose @Nullable InputStream aIS, @WillNotClose @Nullable OutputStream aOS, @Nonnull @Nonempty byte[] aBuffer, @Nullable MutableLong aCopyByteCount, @Nullable Long aLimit)
aIS - The input stream to read from. May be null.
Automatically closed!aOS - The output stream to write to. May be null. Not
automatically closed!aBuffer - The buffer to use. May not be null.aCopyByteCount - An optional mutable long object that will receive the total number
of copied bytes. Note: and optional old value is overwritten!aLimit - An optional maximum number of bytes to copied from the input stream
to the output stream. May be null to indicate no limit,
meaning all bytes are copied.ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwisepublic static int getAvailable(@Nullable InputStream aIS)
aIS - The input stream to use. May be null.null.@Nonnull public static NonBlockingByteArrayOutputStream getCopy(@Nonnull @WillClose InputStream aIS)
aIS - The source input stream. May not be null.NonBlockingByteArrayOutputStream with all available
content inside.@Nonnull public static NonBlockingByteArrayOutputStream getCopyWithLimit(@Nonnull @WillClose InputStream aIS, @Nonnegative long nLimit)
aIS - The source input stream. May not be null.nLimit - The maximum number of bytes to be copied to the output stream. Must
be ≥ 0.NonBlockingByteArrayOutputStream with all available
content inside.@Nullable public static byte[] getAllBytes(@Nullable IHasInputStream aISP)
aISP - The input stream provider to read from. May be null .null if the parameter or the
resolved input stream is null.@Nullable public static byte[] getAllBytes(@Nullable @WillClose InputStream aIS)
aIS - The input stream to read from. May be null.null if the input stream is
null.@Nullable public static String getAllBytesAsString(@Nullable IHasInputStream aISP, @Nonnull @Nonempty Charset aCharset)
aISP - The input stream provider to read from. May be null .aCharset - The charset to use. May not be null .null if the parameter or the resolved
input stream is null.@Nullable public static String getAllBytesAsString(@Nullable @WillClose InputStream aIS, @Nonnull @Nonempty Charset aCharset)
aIS - The input stream to read from. May be null.aCharset - The charset to use. May not be null .null if the input stream is
null.@Nonnull public static ESuccess copyReaderToWriterAndCloseWriter(@WillClose @Nullable Reader aReader, @WillClose @Nullable Writer aWriter)
aReader - The reader to read from. May be null. Automatically
closed!aWriter - The writer to write to. May be null. Automatically
closed!ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyReaderToWriterWithLimitAndCloseWriter(@WillClose @Nullable Reader aReader, @WillClose @Nullable Writer aWriter, @Nonnegative long nLimit)
aReader - The reader to read from. May be null. Automatically
closed!aWriter - The writer to write to. May be null. Automatically
closed!nLimit - The maximum number of chars to be copied to the writer. Must be ≥
0.ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyReaderToWriter(@WillClose @Nullable Reader aReader, @WillNotClose @Nullable Writer aWriter)
aReader - The reader to read from. May be null. Automatically
closed!aWriter - The writer to write to. May be null. Not automatically
closed!ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyReaderToWriter(@WillClose @Nullable Reader aReader, @WillNotClose @Nullable Writer aWriter, @Nullable MutableLong aCopyCharCount)
aReader - The reader to read from. May be null. Automatically
closed!aWriter - The writer to write to. May be null. Not automatically
closed!aCopyCharCount - An optional mutable long object that will receive the total number
of copied characters. Note: and optional old value is overwritten!ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyReaderToWriter(@WillClose @Nullable Reader aReader, @WillNotClose @Nullable Writer aWriter, @Nonnull char[] aBuffer)
aReader - The reader to read from. May be null. Automatically
closed!aWriter - The writer to write to. May be null. Not automatically
closed!aBuffer - The buffer to use. May not be null.ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyReaderToWriterWithLimit(@WillClose @Nullable Reader aReader, @WillNotClose @Nullable Writer aWriter, long nLimit)
aReader - The reader to read from. May be null. Automatically
closed!aWriter - The writer to write to. May be null. Not automatically
closed!nLimit - The maximum number of chars to be copied to the writer. Must be ≥
0.ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyReaderToWriter(@WillClose @Nullable Reader aReader, @WillNotClose @Nullable Writer aWriter, @Nonnull @Nonempty char[] aBuffer, @Nullable MutableLong aCopyCharCount)
aReader - The reader to read from. May be null. Automatically
closed!aWriter - The writer to write to. May be null. Not automatically
closed!aBuffer - The buffer to use. May not be null.aCopyCharCount - An optional mutable long object that will receive the total number
of copied characters. Note: and optional old value is overwritten!ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static ESuccess copyReaderToWriter(@WillClose @Nullable Reader aReader, @WillNotClose @Nullable Writer aWriter, @Nonnull @Nonempty char[] aBuffer, @Nullable MutableLong aCopyCharCount, @Nullable Long aLimit)
aReader - The reader to read from. May be null. Automatically
closed!aWriter - The writer to write to. May be null. Not automatically
closed!aBuffer - The buffer to use. May not be null.aCopyCharCount - An optional mutable long object that will receive the total number
of copied characters. Note: and optional old value is overwritten!aLimit - An optional maximum number of chars to copied from the reader to the
writer. May be null to indicate no limit, meaning all
chars are copied.ESuccess.SUCCESS if copying took place,
ESuccess.FAILURE otherwise@Nonnull public static NonBlockingStringWriter getCopy(@Nonnull @WillClose Reader aReader)
@Nonnull public static NonBlockingStringWriter getCopyWithLimit(@Nonnull @WillClose Reader aReader, @Nonnegative long nLimit)
@Nullable public static char[] getAllCharacters(@Nullable @WillClose Reader aReader)
aReader - The reader to read from. May be null.null if the reader is
null.@Nullable public static String getAllCharactersAsString(@Nullable @WillClose Reader aReader)
aReader - The reader to read from. May be null.null if the reader is
null.@Nullable @ReturnsMutableCopy public static ICommonsList<String> readStreamLines(@Nullable IHasInputStream aISP, @Nonnull Charset aCharset)
aISP - The resource to read. May not be null.aCharset - The character set to use. May not be null.null if the resolved input stream is null
, the content otherwise.@Nullable @ReturnsMutableCopy public static ICommonsList<String> readStreamLines(@Nullable IHasInputStream aISP, @Nonnull Charset aCharset, @Nonnegative int nLinesToSkip, @CheckForSigned int nLinesToRead)
aISP - The resource to read. May be null.aCharset - The character set to use. May not be null.nLinesToSkip - The 0-based index of the first line to read. Pass in 0 to indicate
to read everything.nLinesToRead - The number of lines to read. Pass in CGlobal.ILLEGAL_UINT to
indicate that all lines should be read. If the number passed here
exceeds the number of lines in the file, nothing happens.null if the resolved input stream is null
, the content otherwise.@Nullable @ReturnsMutableCopy public static ICommonsList<String> readStreamLines(@WillClose @Nullable InputStream aIS, @Nonnull @Nonempty Charset aCharset)
aIS - The input stream to read from. May be null.aCharset - The character set to use. May not be null.null if the input stream is null, the
content lines otherwise.public static void readStreamLines(@WillClose @Nullable InputStream aIS, @Nonnull Charset aCharset, @Nonnull List<String> aTargetList)
aIS - The input stream to read from. May be null.aCharset - The character set to use. May not be null.aTargetList - The list to be filled with the lines. May not be null.@Nullable @ReturnsMutableCopy public static ICommonsList<String> readStreamLines(@WillClose @Nullable InputStream aIS, @Nonnull Charset aCharset, @Nonnegative int nLinesToSkip, @CheckForSigned int nLinesToRead)
aIS - The input stream to read from. May be null.aCharset - The character set to use. May not be null.nLinesToSkip - The 0-based index of the first line to read. Pass in 0 to indicate
to read everything.nLinesToRead - The number of lines to read. Pass in CGlobal.ILLEGAL_UINT to
indicate that all lines should be read. If the number passed here
exceeds the number of lines in the file, nothing happens.null if the input stream is null, the
content lines otherwise.public static void readStreamLines(@WillClose @Nullable InputStream aIS, @Nonnull @Nonempty Charset aCharset, @Nonnull Consumer<String> aLineCallback)
aIS - The input stream to read from. May be null.aCharset - The character set to use. May not be null.aLineCallback - The callback that is invoked for all read lines. Each passed line
does NOT contain the line delimiter!public static void readStreamLines(@WillClose @Nullable InputStream aIS, @Nonnull @Nonempty Charset aCharset, @Nonnegative int nLinesToSkip, int nLinesToRead, @Nonnull Consumer<String> aLineCallback)
aIS - The input stream to read from. May be null.aCharset - The character set to use. May not be null.nLinesToSkip - The 0-based index of the first line to read. Pass in 0 to indicate
to read everything.nLinesToRead - The number of lines to read. Pass in CGlobal.ILLEGAL_UINT to
indicate that all lines should be read. If the number passed here
exceeds the number of lines in the file, nothing happens.aLineCallback - The callback that is invoked for all read lines. Each passed line
does NOT contain the line delimiter! Note: it is not invoked for
skipped lines!@Nonnull public static ESuccess writeStream(@WillClose @Nonnull OutputStream aOS, @Nonnull byte[] aBuf, @Nonnegative int nOfs, @Nonnegative int nLen)
OutputStream.aOS - The output stream to write to. May not be null. Is
closed independent of error or success.aBuf - The byte array from which is to be written. May not be
null.nOfs - The 0-based index to the first byte in the array to be written. May
not be < 0.nLen - The non-negative amount of bytes to be written. May not be < 0.ESuccess@Nonnull public static ESuccess writeStream(@WillClose @Nonnull OutputStream aOS, @Nonnull byte[] aBuf)
OutputStream.aOS - The output stream to write to. May not be null. Is
closed independent of error or success.aBuf - The byte array to be written. May not be null.ESuccess@Nonnull public static ESuccess writeStream(@WillClose @Nonnull OutputStream aOS, @Nonnull String sContent, @Nonnull Charset aCharset)
OutputStream.aOS - The output stream to write to. May not be null. Is
closed independent of error or success.sContent - The string to be written. May not be null.aCharset - The charset to be used, to convert the String to a byte array.ESuccess@Nonnull public static NonBlockingStringReader createReader(@Nonnull String sText)
@Nonnull public static NonBlockingStringReader createReader(@Nonnull char[] aChars)
@Nullable public static InputStreamReader createReader(@Nullable InputStream aIS, @Nonnull Charset aCharset)
@Nullable public static OutputStreamWriter createWriter(@Nullable OutputStream aOS, @Nonnull Charset aCharset)
public static void skipFully(@Nonnull InputStream aIS, @Nonnegative long nBytesToSkip) throws IOException
aIS - The input stream to skip in.nBytesToSkip - The number of bytes to skip. Must be ≥ 0.IOException - In case something goes wrong internally@Nonnegative public static int readFully(@Nonnull InputStream aIS, @Nonnull byte[] aBuffer) throws IOException
aIS - The input stream to read from. May not be null.aBuffer - The buffer to write to. May not be null. Must be ≥
than the content to be read.IOException - In case reading fails@Nonnegative public static int readFully(@Nonnull InputStream aIS, @Nonnull byte[] aBuffer, @Nonnegative int nOfs, @Nonnegative int nLen) throws IOException
aIS - The input stream to read from. May not be null.aBuffer - The buffer to write to. May not be null. Must be ≥
than the content to be read.nOfs - The offset into the destination buffer to use. May not be < 0.nLen - The number of bytes to read into the destination buffer to use. May
not be < 0.IOException - In case reading failspublic static boolean isBuffered(@Nullable InputStream aIS)
@Nullable public static InputStream getBuffered(@Nullable InputStream aIS)
public static boolean isBuffered(@Nullable OutputStream aOS)
@Nullable public static OutputStream getBuffered(@Nullable OutputStream aOS)
@Nullable public static InputStream checkForInvalidFilterInputStream(@Nullable InputStream aIS)
public static void writeSafeUTF(@Nonnull DataOutput aDOS, @Nullable String s) throws IOException
DataOutputStream.writeUTF(String) has a limit of 64KB this
methods provides a similar solution but simply writing the bytes.aDOS - DataOutputStream to write to. May not be null.s - The string to be written. May be null.IOException - on write errorreadSafeUTF(DataInput)@Nullable public static String readSafeUTF(@Nonnull DataInput aDIS) throws IOException
DataOutputStream.writeUTF(String) has a limit of 64KB this
methods provides a similar solution for reading like
DataInputStream.readUTF() but what was written in
writeSafeUTF(DataOutput, String).aDIS - DataInputStream to read from. May not be null.null.IOException - on read errorwriteSafeUTF(DataOutput, String)Copyright © 2014–2016 Philip Helger. All rights reserved.