public class StreamUtil
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
close(java.io.Closeable... streams)
Closes the specified streams, suppressing any IOExceptions for inputstreams and readers.
|
static void |
closeNoThrow(java.io.Closeable stream)
Close and swallow exception the exception.
|
static void |
copy(java.io.File fileOrDirectory,
java.io.File toDir)
Recursively copy a file or directory to a directory.
|
static void |
copy(java.io.File fileOrDirectory,
java.io.File toDir,
java.util.function.Predicate<java.io.File> filter) |
static void |
copy(java.io.InputStream in,
java.io.OutputStream out)
Copies the content of an input stream to an output stream.
|
static void |
copy(java.io.InputStream in,
java.io.Writer writer)
Copies the content of an input stream to a writer.
|
static void |
copy(java.nio.file.Path fileOrDirectory,
java.nio.file.Path toDir)
Recursively copy a file or directory to a directory.
|
static void |
copy(java.io.Reader reader,
java.io.OutputStream out)
Copies the content of a reader to an output stream.
|
static void |
copy(java.io.Reader in,
java.io.Writer out)
Copies the content of a reader to a writer.
|
static byte[] |
getContent(java.io.InputStream in)
Returns the content of the specified input stream.
|
static java.lang.String |
getContent(java.io.Reader in)
Returns the content of the specified reader.
|
static java.io.Reader |
getInputStreamReader(java.io.InputStream in)
Returns a reader for the specified input stream, using UTF-8 encoding.
|
static java.io.Reader |
getInputStreamReader(java.io.InputStream in,
java.lang.String charset)
Returns a reader for the specified input stream, using specified encoding.
|
static java.io.Writer |
getOutputStreamWriter(java.io.OutputStream out)
Returns a writer for the specified output stream, using UTF-8 encoding.
|
static java.io.InputStream |
getStringInputStream(java.lang.CharSequence cs)
Returns an input stream for the specified character sequence, using UTF-8 encoding.
|
static byte[] |
toBytes(java.lang.CharSequence seq)
Converts the specified character sequence to bytes using UTF-8.
|
static java.util.Properties |
toProperties(java.lang.String propFileText)
Converts the specified property file text to a Properties object.
|
static java.lang.String |
toString(byte[] bytes)
Converts the specified byte array to a String using UTF-8.
|
static java.lang.String |
toString(byte[] bytes,
int offset,
int length)
Converts the specified byte array to a String using UTF-8.
|
public static byte[] toBytes(java.lang.CharSequence seq)
seq - the character sequence to convertpublic static java.lang.String toString(byte[] bytes)
bytes - the bytes to convertpublic static java.lang.String toString(byte[] bytes,
int offset,
int length)
bytes - the bytes to convertoffset - the index of the first byte to decodelength - the number of bytes to decodepublic static java.util.Properties toProperties(java.lang.String propFileText)
throws java.nio.charset.CharacterCodingException
propFileText - the property file text in standard property file formatjava.nio.charset.CharacterCodingException - if invalid encodingpublic static java.io.Reader getInputStreamReader(java.io.InputStream in)
in - the input stream to wrappublic static java.io.Reader getInputStreamReader(java.io.InputStream in,
java.lang.String charset)
in - the input stream to wrapcharset - the input stream to wrappublic static java.io.Writer getOutputStreamWriter(java.io.OutputStream out)
out - the output stream to wrappublic static java.io.InputStream getStringInputStream(java.lang.CharSequence cs)
cs - the character sequence to wrappublic static byte[] getContent(java.io.InputStream in)
throws java.io.IOException
in - the input stream to readjava.io.IOException - if an I/O error occurspublic static java.lang.String getContent(java.io.Reader in)
throws java.io.IOException
in - the reader to readjava.io.IOException - if an I/O error occurspublic static void copy(java.io.InputStream in,
java.io.OutputStream out)
throws java.io.IOException
in - the input stream to readout - the output stream to writejava.io.IOException - if an I/O error occurspublic static void copy(java.io.InputStream in,
java.io.Writer writer)
throws java.io.IOException
in - the input stream to readwriter - the writer to writejava.io.IOException - if an I/O error occurspublic static void copy(java.io.Reader reader,
java.io.OutputStream out)
throws java.io.IOException
reader - the reader to readout - the output stream to writejava.io.IOException - if an I/O error occurspublic static void copy(java.io.Reader in,
java.io.Writer out)
throws java.io.IOException
in - the reader to readout - the writer to writejava.io.IOException - if an I/O error occurspublic static void copy(java.io.File fileOrDirectory,
java.io.File toDir)
public static void copy(java.io.File fileOrDirectory,
java.io.File toDir,
java.util.function.Predicate<java.io.File> filter)
public static void copy(java.nio.file.Path fileOrDirectory,
java.nio.file.Path toDir)
public static void closeNoThrow(java.io.Closeable stream)
stream - the streams to closepublic static void close(java.io.Closeable... streams)
throws java.io.IOException
streams - the streams to closejava.io.IOException - if an i/o exception occurs while closing any outputstream or writerCopyright © 2024. All rights reserved.