- java.lang.Object
-
- com.aoapps.lang.io.IoUtils
-
public final class IoUtils extends Object
I/O utilities.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static charbufferToChar(byte[] ioBuffer)static charbufferToChar(byte[] ioBuffer, int off)static intbufferToInt(byte[] ioBuffer)static intbufferToInt(byte[] ioBuffer, int off)static longbufferToLong(byte[] ioBuffer)static longbufferToLong(byte[] ioBuffer, int off)static shortbufferToShort(byte[] ioBuffer)static shortbufferToShort(byte[] ioBuffer, int off)static voidcharToBuffer(char ch, byte[] ioBuffer)static voidcharToBuffer(char ch, byte[] ioBuffer, int off)static booleancontentEquals(InputStream in, byte[] contents)Compares the contents retrieved from an InputStream to the provided contents.static longcopy(InputStream in, OutputStream out)copies without flush.static longcopy(InputStream in, OutputStream out, boolean flush)Copies all information from one stream to another.static longcopy(Reader in, Writer out)Copies all information from one stream to another.static longcopy(Reader in, Appendable out)Copies all information from one stream to an appendable.static longcopy(Reader in, StringBuilder out)Copies all information from one stream to another.static voidintToBuffer(int i, byte[] ioBuffer)static voidintToBuffer(int i, byte[] ioBuffer, int off)static voidlongToBuffer(long l, byte[] ioBuffer)static voidlongToBuffer(long l, byte[] ioBuffer, int off)static byte[]readFully(InputStream in)Reads an input stream fully (to end of stream), returning a byte[] of the content read.static voidreadFully(InputStream in, byte[] buffer)readFully for any stream.static voidreadFully(InputStream in, byte[] buffer, int off, int len)readFully for any stream.static StringreadFully(Reader in)Reads a reader fully (to end of stream), returning a String of the content read.static voidshortToBuffer(short s, byte[] ioBuffer)static voidshortToBuffer(short s, byte[] ioBuffer, int off)
-
-
-
Method Detail
-
copy
public static long copy(InputStream in, OutputStream out) throws IOException
copies without flush.- Throws:
IOException- See Also:
copy(java.io.InputStream, java.io.OutputStream, boolean)
-
copy
public static long copy(InputStream in, OutputStream out, boolean flush) throws IOException
Copies all information from one stream to another. Internally reuses thread-local buffers to avoid initial buffer zeroing cost and later garbage collection overhead.- Returns:
- the number of bytes copied
- Throws:
IOException- See Also:
BufferManager.getBytes()
-
copy
public static long copy(Reader in, Writer out) throws IOException
Copies all information from one stream to another. Internally reuses thread-local buffers to avoid initial buffer zeroing cost and later garbage collection overhead.- Returns:
- the number of bytes copied
- Throws:
IOException- See Also:
BufferManager.getChars()
-
copy
public static long copy(Reader in, Appendable out) throws IOException
Copies all information from one stream to an appendable.- Returns:
- the number of bytes copied
- Throws:
IOException- See Also:
BufferManager.getChars()
-
copy
public static long copy(Reader in, StringBuilder out) throws IOException
Copies all information from one stream to another. Internally reuses thread-local buffers to avoid initial buffer zeroing cost and later garbage collection overhead.- Returns:
- the number of bytes copied
- Throws:
IOException- See Also:
BufferManager.getChars()
-
readFully
public static void readFully(InputStream in, byte[] buffer) throws IOException
readFully for any stream.- Throws:
IOException
-
readFully
public static void readFully(InputStream in, byte[] buffer, int off, int len) throws IOException
readFully for any stream.- Throws:
IOException
-
readFully
public static byte[] readFully(InputStream in) throws IOException
Reads an input stream fully (to end of stream), returning a byte[] of the content read.- Throws:
IOException
-
readFully
public static String readFully(Reader in) throws IOException
Reads a reader fully (to end of stream), returning a String of the content read.- Throws:
IOException
-
contentEquals
public static boolean contentEquals(InputStream in, byte[] contents) throws IOException
Compares the contents retrieved from an InputStream to the provided contents.- Returns:
- true when the contents exactly match
- Throws:
IOException
-
charToBuffer
public static void charToBuffer(char ch, byte[] ioBuffer)
-
charToBuffer
public static void charToBuffer(char ch, byte[] ioBuffer, int off)
-
bufferToChar
public static char bufferToChar(byte[] ioBuffer)
-
bufferToChar
public static char bufferToChar(byte[] ioBuffer, int off)
-
shortToBuffer
public static void shortToBuffer(short s, byte[] ioBuffer)
-
shortToBuffer
public static void shortToBuffer(short s, byte[] ioBuffer, int off)
-
bufferToShort
public static short bufferToShort(byte[] ioBuffer)
-
bufferToShort
public static short bufferToShort(byte[] ioBuffer, int off)
-
intToBuffer
public static void intToBuffer(int i, byte[] ioBuffer)
-
intToBuffer
public static void intToBuffer(int i, byte[] ioBuffer, int off)
-
bufferToInt
public static int bufferToInt(byte[] ioBuffer)
-
bufferToInt
public static int bufferToInt(byte[] ioBuffer, int off)
-
longToBuffer
public static void longToBuffer(long l, byte[] ioBuffer)
-
longToBuffer
public static void longToBuffer(long l, byte[] ioBuffer, int off)
-
bufferToLong
public static long bufferToLong(byte[] ioBuffer)
-
bufferToLong
public static long bufferToLong(byte[] ioBuffer, int off)
-
-