public class IO extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
bufferSize |
static String |
CRLF |
static byte[] |
CRLF_BYTES |
| Constructor and Description |
|---|
IO() |
| Modifier and Type | Method and Description |
|---|---|
static void |
close(Closeable closeable)
Closes an arbitrary closable, and logs exceptions at ignore level
|
static void |
close(InputStream is)
closes an input stream, and logs exceptions
|
static void |
close(OutputStream os)
closes an output stream, and logs exceptions
|
static void |
close(Reader reader)
closes a reader, and logs exceptions
|
static void |
close(Writer writer)
closes a writer, and logs exceptions
|
static void |
copy(File from,
File to)
Copy files or directories
|
static void |
copy(InputStream in,
OutputStream out)
Copy Stream in to Stream out until EOF or exception.
|
static void |
copy(InputStream in,
OutputStream out,
long byteCount)
Copy Stream in to Stream for byteCount bytes or until EOF or exception.
|
static void |
copy(Reader in,
Writer out)
Copy Reader to Writer out until EOF or exception.
|
static void |
copy(Reader in,
Writer out,
long byteCount)
Copy Reader to Writer for byteCount bytes or until EOF or exception.
|
static void |
copyDir(File from,
File to) |
static void |
copyFile(File from,
File to) |
static boolean |
delete(File file)
Delete File.
|
static InputStream |
getClosedStream() |
static PrintWriter |
getNullPrintWriter() |
static OutputStream |
getNullStream() |
static Writer |
getNullWriter() |
static byte[] |
readBytes(InputStream in) |
static String |
toString(InputStream in)
Read input stream to string.
|
static String |
toString(InputStream in,
Charset encoding)
Read input stream to string.
|
static String |
toString(InputStream in,
String encoding)
Read input stream to string.
|
static String |
toString(Reader in)
Read input stream to string.
|
static long |
write(GatheringByteChannel out,
ByteBuffer[] buffers,
int offset,
int length)
A gathering write utility wrapper.
|
public static final String CRLF
public static final byte[] CRLF_BYTES
public static final int bufferSize
public static void copy(InputStream in, OutputStream out) throws IOException
in - the input stream to read from (until EOF)out - the output stream to write toIOException - if unable to copy streamspublic static void copy(Reader in, Writer out) throws IOException
in - the read to read from (until EOF)out - the writer to write toIOException - if unable to copy the streamspublic static void copy(InputStream in, OutputStream out, long byteCount) throws IOException
in - the stream to read fromout - the stream to write tobyteCount - the number of bytes to copyIOException - if unable to copy the streamspublic static void copy(Reader in, Writer out, long byteCount) throws IOException
in - the Reader to read fromout - the Writer to write tobyteCount - the number of bytes to copyIOException - if unable to copy streamspublic static void copy(File from, File to) throws IOException
from - the file to copyto - the destination to copy toIOException - if unable to copypublic static void copyDir(File from, File to) throws IOException
IOExceptionpublic static void copyFile(File from, File to) throws IOException
IOExceptionpublic static String toString(InputStream in) throws IOException
in - the stream to read from (until EOF)IOException - if unable to read the stream (or handle the charset)public static String toString(InputStream in, String encoding) throws IOException
in - the stream to read from (until EOF)encoding - the encoding to use (can be null to use default Charset)IOException - if unable to read the stream (or handle the charset)public static String toString(InputStream in, Charset encoding) throws IOException
in - the stream to read from (until EOF)encoding - the Charset to use (can be null to use default Charset)IOException - if unable to read the stream (or handle the charset)public static String toString(Reader in) throws IOException
in - the reader to read from (until EOF)IOException - if unable to read the stream (or handle the charset)public static boolean delete(File file)
file - The file (or directory) to be deleted.public static void close(Closeable closeable)
closeable - the closeable to closepublic static void close(InputStream is)
is - the input stream to closepublic static void close(OutputStream os)
os - the output stream to closepublic static void close(Reader reader)
reader - the reader to closepublic static void close(Writer writer)
writer - the writer to closepublic static byte[] readBytes(InputStream in) throws IOException
IOExceptionpublic static long write(GatheringByteChannel out, ByteBuffer[] buffers, int offset, int length) throws IOException
This method wraps a gather write with a loop that handles the limitations of some operating systems that have a limit on the number of buffers written. The method loops on the write until either all the content is written or no progress is made.
out - The GatheringByteChannel to write tobuffers - The buffers to writeoffset - The offset into the buffers arraylength - The length in buffers to writeIOException - if unable write to the GatheringByteChannelpublic static OutputStream getNullStream()
public static InputStream getClosedStream()
public static Writer getNullWriter()
public static PrintWriter getNullPrintWriter()
Copyright © 2010 - 2020 Adobe. All Rights Reserved