liquibase.util
Class StreamUtil

java.lang.Object
  extended by liquibase.util.StreamUtil

public class StreamUtil
extends java.lang.Object

Utilities for working with streams.


Field Summary
static java.lang.String lineSeparator
           
 
Constructor Summary
StreamUtil()
           
 
Method Summary
static void copy(java.io.InputStream inputStream, java.io.OutputStream outputStream)
           
static java.lang.String getLineSeparator()
           
static java.lang.String getReaderContents(java.io.Reader reader)
          Reads all the characters into a String.
static java.lang.String getStreamContents(java.io.InputStream ins)
          Reads a stream until the end of file into a String and uses the machines default encoding to convert to characters the bytes from the Stream.
static java.lang.String getStreamContents(java.io.InputStream ins, java.lang.String charsetName)
          Reads a stream until the end of file into a String and uses the machines default encoding to convert to characters the bytes from the Stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lineSeparator

public static final java.lang.String lineSeparator
Constructor Detail

StreamUtil

public StreamUtil()
Method Detail

getLineSeparator

public static java.lang.String getLineSeparator()

getStreamContents

public static java.lang.String getStreamContents(java.io.InputStream ins)
                                          throws java.io.IOException
Reads a stream until the end of file into a String and uses the machines default encoding to convert to characters the bytes from the Stream.

Parameters:
ins - The InputStream to read.
Returns:
The contents of the input stream as a String
Throws:
java.io.IOException - If there is an error reading the stream.

getStreamContents

public static java.lang.String getStreamContents(java.io.InputStream ins,
                                                 java.lang.String charsetName)
                                          throws java.io.IOException
Reads a stream until the end of file into a String and uses the machines default encoding to convert to characters the bytes from the Stream.

Parameters:
ins - The InputStream to read.
charsetName - The name of a supported charset
Returns:
The contents of the input stream as a String
Throws:
java.io.IOException - If there is an error reading the stream.

getReaderContents

public static java.lang.String getReaderContents(java.io.Reader reader)
                                          throws java.io.IOException
Reads all the characters into a String.

Parameters:
reader - The Reader to read.
Returns:
The contents of the input stream as a String
Throws:
java.io.IOException - If there is an error reading the stream.

copy

public static void copy(java.io.InputStream inputStream,
                        java.io.OutputStream outputStream)
                 throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2010 Liquibase.org. All Rights Reserved.