Class IOUtils


  • public class IOUtils
    extends java.lang.Object
    IO Stream static utilities.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void copy​(java.io.InputStream in, java.io.OutputStream out)
      Copy all available data from one stream to another.
      static java.lang.String readString​(java.io.InputStream is)
      Read next string from input stream.
      static java.lang.String readString​(java.io.InputStream is, char term)
      Read next string from input stream.
      static java.lang.String readString​(java.io.InputStream is, java.lang.String term)
      Read next string from input stream.
      static java.lang.String readString​(java.io.Reader is)
      Read next string from input stream.
      static java.lang.String readString​(java.io.Reader is, char term)
      Read next string from input stream.
      static java.lang.String readString​(java.io.Reader is, java.lang.String term)
      Read next string from input stream.
      static boolean skipUntil​(java.io.InputStream in, byte separator)
      Skip all bytes in stream until (and including) given byte is found.
      static boolean skipUntil​(java.io.InputStream in, byte[] separator)
      Skip all bytes in stream until (and including) given separator is found.
      static boolean skipUntil​(java.io.Reader in, char separator)
      Skip all bytes in stream until (and including) given byte is found.
      static boolean skipUntil​(java.io.Reader in, java.lang.String separator)
      Skip all bytes in stream until (and including) given separator is found.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • skipUntil

        public static boolean skipUntil​(java.io.InputStream in,
                                        byte[] separator)
                                 throws java.io.IOException
        Skip all bytes in stream until (and including) given separator is found.
        Parameters:
        in - Input stream to read from.
        separator - Separator bytes to skip until.
        Returns:
        True iff the separator was encountered.
        Throws:
        java.io.IOException - if unable to read from stream.
      • skipUntil

        public static boolean skipUntil​(java.io.Reader in,
                                        java.lang.String separator)
                                 throws java.io.IOException
        Skip all bytes in stream until (and including) given separator is found.
        Parameters:
        in - Input stream to read from.
        separator - Separator bytes to skip until.
        Returns:
        True iff the separator was encountered.
        Throws:
        java.io.IOException - if unable to read from stream.
      • skipUntil

        public static boolean skipUntil​(java.io.InputStream in,
                                        byte separator)
                                 throws java.io.IOException
        Skip all bytes in stream until (and including) given byte is found.
        Parameters:
        in - Input stream to read from.
        separator - Byte to skip until.
        Returns:
        True iff the separator was encountered.
        Throws:
        java.io.IOException - if unable to read from stream.
      • skipUntil

        public static boolean skipUntil​(java.io.Reader in,
                                        char separator)
                                 throws java.io.IOException
        Skip all bytes in stream until (and including) given byte is found.
        Parameters:
        in - Input stream to read from.
        separator - Byte to skip until.
        Returns:
        True iff the separator was encountered.
        Throws:
        java.io.IOException - if unable to read from stream.
      • copy

        public static void copy​(java.io.InputStream in,
                                java.io.OutputStream out)
                         throws java.io.IOException
        Copy all available data from one stream to another.
        Parameters:
        in - The stream to read fromn.
        out - The stream to write to.
        Throws:
        java.io.IOException - If unable to read from or write to streams.
      • readString

        public static java.lang.String readString​(java.io.InputStream is)
                                           throws java.io.IOException
        Read next string from input stream.
        Parameters:
        is - The input stream to read.
        Returns:
        The resulting string.
        Throws:
        java.io.IOException - when unable to read from stream.
      • readString

        public static java.lang.String readString​(java.io.InputStream is,
                                                  java.lang.String term)
                                           throws java.io.IOException
        Read next string from input stream.
        Parameters:
        is - The input stream to read.
        term - Terminator character.
        Returns:
        The string up until, but not including the terminator.
        Throws:
        java.io.IOException - when unable to read from stream.
      • readString

        public static java.lang.String readString​(java.io.InputStream is,
                                                  char term)
                                           throws java.io.IOException
        Read next string from input stream.
        Parameters:
        is - The input stream to read.
        term - Terminator character.
        Returns:
        The string up until, but not including the terminator.
        Throws:
        java.io.IOException - when unable to read from stream.
      • readString

        public static java.lang.String readString​(java.io.Reader is)
                                           throws java.io.IOException
        Read next string from input stream. The terminator is read but not included in the resulting string.
        Parameters:
        is - The input stream to read.
        Returns:
        The string up until, but not including the terminator.
        Throws:
        java.io.IOException - when unable to read from stream.
      • readString

        public static java.lang.String readString​(java.io.Reader is,
                                                  char term)
                                           throws java.io.IOException
        Read next string from input stream.
        Parameters:
        is - The reader to read characters from.
        term - Terminator character.
        Returns:
        The string up until, but not including the terminator.
        Throws:
        java.io.IOException - when unable to read from stream.
      • readString

        public static java.lang.String readString​(java.io.Reader is,
                                                  java.lang.String term)
                                           throws java.io.IOException
        Read next string from input stream.
        Parameters:
        is - The reader to read characters from.
        term - Terminator character.
        Returns:
        The string up until, but not including the terminator.
        Throws:
        java.io.IOException - when unable to read from stream.