Class StreamTools


  • public class StreamTools
    extends java.lang.Object
    A tool class for the handling of streams.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_BUFFER  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void close​(IRandomAccess ra)  
      static void close​(java.io.InputStream is)  
      static void close​(java.io.OutputStream os)  
      static void close​(java.io.RandomAccessFile ra)  
      static void close​(java.io.Reader reader)  
      static void close​(java.io.Writer writer)  
      static void copyEncoded​(java.io.Reader reader, java.io.Writer writer)  
      static void copyEncodedStream​(java.io.InputStream source, java.lang.String sourceEncoding, java.io.OutputStream destination, java.lang.String destinationEncoding)  
      static void copyStream​(java.io.InputStream source, boolean closeInput, java.io.OutputStream destination, boolean closeOutput)
      Kopiert einen Eingabedatenstrom auf einen Ausgabedatenstrom.
      static void copyStream​(java.io.InputStream source, java.io.OutputStream destination)
      Kopiert einen Stream.
      static void copyStream​(java.io.InputStream source, java.io.OutputStream destination, long length)
      Kopiert einen Eingabedatenstrom auf einen Ausgabedatenstrom.
      static byte[] toByteArray​(java.io.InputStream is)  
      static java.lang.String toString​(java.io.InputStream is, java.lang.String encoding)  
      static java.lang.String toString​(java.io.Reader r)  
      • Methods inherited from class java.lang.Object

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

      • close

        public static void close​(java.io.InputStream is)
      • close

        public static void close​(java.io.OutputStream os)
      • close

        public static void close​(java.io.RandomAccessFile ra)
      • close

        public static void close​(java.io.Reader reader)
      • close

        public static void close​(java.io.Writer writer)
      • copyEncoded

        public static void copyEncoded​(java.io.Reader reader,
                                       java.io.Writer writer)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • copyEncodedStream

        public static void copyEncodedStream​(java.io.InputStream source,
                                             java.lang.String sourceEncoding,
                                             java.io.OutputStream destination,
                                             java.lang.String destinationEncoding)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • copyStream

        public static void copyStream​(java.io.InputStream source,
                                      boolean closeInput,
                                      java.io.OutputStream destination,
                                      boolean closeOutput)
                               throws java.io.IOException
        Kopiert einen Eingabedatenstrom auf einen Ausgabedatenstrom. Anschließend (finally) werden die Datenströme geschlossen(!), sofern dies in den Parametern angegeben wurde. Fehler beim Schließen der Datenströme werden ignoriert.
        Parameters:
        source - Eingabedatenstrom
        closeInput - Angabe ob der InputStream nach dem Kopieren geschlossen werden soll.
        destination - Ausgabedatenstrom
        closeOutput - Angabe ob der OutputStream nach dem Kopieren geschlossen werden soll.
        Throws:
        java.io.IOException - Fehler allgemein oder beim Kopieren.
      • copyStream

        public static void copyStream​(java.io.InputStream source,
                                      java.io.OutputStream destination)
                               throws java.io.IOException
        Kopiert einen Stream. Ruft copyStream(in, true, out, true) auf.
        Parameters:
        source - Eingabedatenstrom, der kopiert werden soll.
        destination - Ausgabestrom, auf den kopiert werden soll.
        Throws:
        java.io.IOException
        See Also:
        copyStream(InputStream, boolean, OutputStream, boolean)
      • copyStream

        public static void copyStream​(java.io.InputStream source,
                                      java.io.OutputStream destination,
                                      long length)
                               throws java.io.IOException
        Kopiert einen Eingabedatenstrom auf einen Ausgabedatenstrom.
        Parameters:
        source - Eingabedatenstrom
        destination - Ausgabedatenstrom
        length - Anzahl der zu lesenden bytes
        Throws:
        java.io.IOException
      • toByteArray

        public static byte[] toByteArray​(java.io.InputStream is)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • toString

        public static java.lang.String toString​(java.io.InputStream is,
                                                java.lang.String encoding)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • toString

        public static java.lang.String toString​(java.io.Reader r)
                                         throws java.io.IOException
        Throws:
        java.io.IOException