Class IoUtils


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

      • 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,
                                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 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)