Module tvbrowser

Class StreamUtilities


  • public class StreamUtilities
    extends java.lang.Object
    Stream processor class for working with streams This class does all the IOException handling for working with streams, so you can concentrate on your algorithm instead.
    Since:
    3.0
    Author:
    Bananeweizen
    • Constructor Detail

      • StreamUtilities

        public StreamUtilities()
    • Method Detail

      • inputStream

        public static void inputStream​(java.io.File file,
                                       InputStreamProcessor processor)
                                throws java.io.IOException
        Lets you work with a file based input stream. It is guaranteed that the underlying stream is closed, even if IOExceptions occur (which are still thrown further to the caller of this method)
        Parameters:
        file - The file
        processor - The processor
        Throws:
        java.io.IOException - Thrown if an IO operation went wrong.
        Since:
        3.0
      • inputStream

        public static void inputStream​(java.net.URLConnection urlConnection,
                                       InputStreamProcessor processor)
                                throws java.io.IOException
        Lets you work with a URL based input stream. It is guaranteed that the underlying stream is closed, even if IOExceptions occur (which are still thrown further to the caller of this method)
        Parameters:
        urlConnection - The url connection.
        processor - The processor.
        Throws:
        java.io.IOException - Thrown if an IO operation went wrong.
        Since:
        3.0
      • inputStream

        public static void inputStream​(java.io.InputStream inputStream,
                                       InputStreamProcessor processor)
                                throws java.io.IOException
        Lets you work with a generic input stream. It is guaranteed that the stream is closed after the method, even if IOExceptions occur (which are still thrown further to the caller of this method)
        Parameters:
        inputStream - The input stream.
        processor - The processor.
        Throws:
        java.io.IOException - Thrown if an IO operation went wrong.
        Since:
        3.0
      • inputStreamIgnoringExceptions

        public static void inputStreamIgnoringExceptions​(java.lang.String fileName,
                                                         InputStreamProcessor processor)
        Lets you work with a file name based input stream. It is guaranteed that the underlying stream is closed, even if IOExceptions occur (which are not thrown)
        Parameters:
        fileName - The file name.
        processor - The processor.
        Since:
        3.0
      • inputStreamIgnoringExceptions

        public static void inputStreamIgnoringExceptions​(java.io.File file,
                                                         InputStreamProcessor processor)
      • inputStream

        public static void inputStream​(java.lang.String fileName,
                                       InputStreamProcessor processor)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • inputStream

        public static void inputStream​(java.net.URL url,
                                       InputStreamProcessor processor)
                                throws java.io.IOException
        Lets you work with a file based input stream. It is guaranteed that the underlying stream is closed, even if IOExceptions occur (which are still thrown further to the caller of this method)
        Parameters:
        url - URL to open
        processor - The processor.
        Throws:
        java.io.IOException - Thrown if an IO operation went wrong.
        Since:
        3.0
      • bufferedReader

        public static void bufferedReader​(java.io.File file,
                                          BufferedReaderProcessor processor)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • bufferedReaderIgnoringExceptions

        public static void bufferedReaderIgnoringExceptions​(java.io.File file,
                                                            BufferedReaderProcessor processor)
      • bufferedReader

        public static void bufferedReader​(java.lang.String fileName,
                                          BufferedReaderProcessor processor)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • outputStream

        public static void outputStream​(java.io.File file,
                                        OutputStreamProcessor processor)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • outputStream

        public static void outputStream​(java.lang.String fileName,
                                        OutputStreamProcessor processor)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • objectOutputStream

        public static void objectOutputStream​(java.io.File file,
                                              ObjectOutputStreamProcessor processor)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • objectOutputStreamIgnoringExceptions

        public static void objectOutputStreamIgnoringExceptions​(java.io.File file,
                                                                ObjectOutputStreamProcessor processor)
      • bufferedWriter

        public static void bufferedWriter​(java.io.File file,
                                          BufferedWriterProcessor processor)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • bufferedWriterIgnoringExceptions

        public static void bufferedWriterIgnoringExceptions​(java.io.File file,
                                                            BufferedWriterProcessor processor)
      • objectInputStream

        public static void objectInputStream​(java.io.File file,
                                             ObjectInputStreamProcessor processor)
                                      throws java.io.IOException
        Lets you work with a file based input stream. It is guaranteed that the underlying stream is closed, even if IOExceptions occur (which are still thrown further to the caller of this method)
        Parameters:
        file - The file.
        processor - The processor.
        Throws:
        java.io.IOException - Thrown if an IO operation went wrong.
        Since:
        3.0
      • objectInputStream

        public static void objectInputStream​(java.io.File file,
                                             int bufferSize,
                                             ObjectInputStreamProcessor processor)
                                      throws java.io.IOException
        Lets you work with a file based input stream. It is guaranteed that the underlying stream is closed, even if IOExceptions occur (which are still thrown further to the caller of this method)
        Parameters:
        file - The file.
        processor - The processor.
        bufferSize - The buffer size.
        Throws:
        java.io.IOException - Thrown if an IO operation went wrong.
        Since:
        3.0
      • objectInputStreamIgnoringExceptions

        public static void objectInputStreamIgnoringExceptions​(java.io.File file,
                                                               ObjectInputStreamProcessor processor)
      • objectInputStreamIgnoringExceptions

        public static void objectInputStreamIgnoringExceptions​(java.io.File file,
                                                               int bufferSize,
                                                               ObjectInputStreamProcessor processor)
      • printStream

        public static void printStream​(java.io.File file,
                                       boolean autoFlush,
                                       java.lang.String encoding,
                                       PrintStreamProcessor processor)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • printStream

        public static void printStream​(java.io.File file,
                                       PrintStreamProcessor processor)
                                throws java.io.IOException
        Throws:
        java.io.IOException