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, boolean closeInput, Writer writer, boolean closeOutput)
           
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 byte[] getBytes(InputStream is)
          The complete content of the InputStream as a byte array.
static void putBytes(OutputStream os, byte[] bytes)
          Write all bytes to OutputStream.
static byte[] toByteArray(InputStream is)
          The complete content of the InputStream as a byte array.
static String toString(InputStream is, String encoding)
          The complete content of the InputStream as a String, converted using the specified encoding.
static String toString(Reader r)
          The complete content of the Reader as a String.
 
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,
                               boolean closeInput,
                               Writer writer,
                               boolean closeOutput)
                        throws IOException
Throws:
IOException

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)

getBytes

public static byte[] getBytes(InputStream is)
                       throws IOException
The complete content of the InputStream as a byte array. The input stream is closed.

Parameters:
is -
Returns:
The complete content of the InputStream as a byte array.
Throws:
IOException

putBytes

public static void putBytes(OutputStream os,
                            byte[] bytes)
                     throws IOException
Write all bytes to OutputStream. The stream is closed.

Parameters:
os -
bytes -
Throws:
IOException

toByteArray

public static byte[] toByteArray(InputStream is)
                          throws IOException
The complete content of the InputStream as a byte array. The input stream is closed.

Parameters:
is -
Returns:
The complete content of the InputStream as a byte array.
Throws:
IOException

toString

public static String toString(InputStream is,
                              String encoding)
                       throws IOException
The complete content of the InputStream as a String, converted using the specified encoding. If no encoding is specified, the default encoding is used. The input stream is closed.

Parameters:
is -
encoding -
Returns:
The complete content of the InputStream as a String
Throws:
IOException

toString

public static String toString(Reader r)
                       throws IOException
The complete content of the Reader as a String. The reader is closed.

Parameters:
r -
Returns:
The complete content of the Reader as a String.
Throws:
IOException

intarsys runtime library

Copyright © 2012 intarsys consulting GmbH. All Rights Reserved.