Class IoUtils

java.lang.Object
com.aoapps.lang.io.IoUtils

public final class IoUtils extends Object
I/O utilities.
  • Method Details

    • copy

      public static long copy(InputStream in, OutputStream out) throws IOException
      copies without flush.
      Throws:
      IOException
      See Also:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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)