intarsys runtime library

de.intarsys.tools.stream
Class StreamTools

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

public class StreamTools
extends Object

A tool class for the handling of streams.


Field Summary
static int MAX_BUFFER
           
 
Method Summary
static void close(InputStream is)
           
static void close(IRandomAccess ra)
           
static void close(OutputStream os)
           
static void close(RandomAccessFile ra)
           
static void close(Reader reader)
           
static void close(Writer writer)
           
static void copyEncoded(Reader reader, Writer writer)
           
static void copyEncodedStream(InputStream source, String sourceEncoding, OutputStream destination, String destinationEncoding)
           
static void copyStream(InputStream source, boolean closeInput, OutputStream destination, boolean closeOutput)
          Kopiert einen Eingabedatenstrom auf einen Ausgabedatenstrom.
static void copyStream(InputStream source, OutputStream destination)
          Kopiert einen Stream.
static void copyStream(InputStream source, OutputStream destination, long length)
          Kopiert einen Eingabedatenstrom auf einen Ausgabedatenstrom.
static byte[] toByteArray(InputStream is)
           
static String toString(InputStream is, String encoding)
           
static String toString(Reader r)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_BUFFER

public static final int MAX_BUFFER
See Also:
Constant Field Values
Method Detail

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(InputStream, boolean, OutputStream, boolean)

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

intarsys runtime library

Copyright © 2008 intarsys consulting GmbH. All Rights Reserved.