Class StreamTools

java.lang.Object
de.intarsys.tools.stream.StreamTools

public class StreamTools extends Object
A tool class for the handling of streams.
  • Field Details

  • Method Details

    • close

      public static void close(InputStream is)
    • close

      public static void close(IRandomAccess ra)
    • close

      public static void close(OutputStream os)
    • close

      public static void close(RandomAccessFile ra)
    • close

      public static void close(Reader reader)
    • close

      public static void close(Writer writer)
    • copyEncoded

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

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

      public static void copyStream(InputStream source, boolean closeInput, OutputStream destination, boolean closeOutput) throws 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:
      IOException - Fehler allgemein oder beim Kopieren.
    • copyStream

      public static void copyStream(InputStream source, OutputStream destination) throws 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:
      IOException
      See Also:
    • copyStream

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

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

      public static String toString(InputStream is, String encoding) throws IOException
      Throws:
      IOException
    • toString

      public static String toString(Reader r) throws IOException
      Throws:
      IOException