liquibase.util
Class StreamUtil

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

public class StreamUtil
extends Object

Utilities for working with streams.


Constructor Summary
StreamUtil()
           
 
Method Summary
static void closeQuietly(Closeable input)
           
static void closeQuietly(InputStream input)
           
static void closeQuietly(Reader input)
           
static void copy(InputStream inputStream, OutputStream outputStream)
           
static long getContentLength(InputStream in)
           
static long getContentLength(Reader reader)
           
static String getLineSeparator()
           
static String getReaderContents(Reader reader)
          Reads all the characters into a String.
static String getStreamContents(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 String getStreamContents(InputStream ins, 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.
static InputStream openStream(String path, Boolean relativeToChangelogFile, ChangeSet changeSet, ResourceAccessor resourceAccessor)
           
static InputStream singleInputStream(String path, ResourceAccessor resourceAccessor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamUtil

public StreamUtil()
Method Detail

getLineSeparator

public static String getLineSeparator()

getStreamContents

public static String getStreamContents(InputStream ins)
                                throws 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:
IOException - If there is an error reading the stream.

getStreamContents

public static String getStreamContents(InputStream ins,
                                       String charsetName)
                                throws 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:
IOException - If there is an error reading the stream.

getReaderContents

public static String getReaderContents(Reader reader)
                                throws 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:
IOException - If there is an error reading the stream.

copy

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

getContentLength

public static long getContentLength(InputStream in)
                             throws IOException
Throws:
IOException

getContentLength

public static long getContentLength(Reader reader)
                             throws IOException
Throws:
IOException

closeQuietly

public static void closeQuietly(Reader input)

closeQuietly

public static void closeQuietly(InputStream input)

closeQuietly

public static void closeQuietly(Closeable input)

openStream

public static InputStream openStream(String path,
                                     Boolean relativeToChangelogFile,
                                     ChangeSet changeSet,
                                     ResourceAccessor resourceAccessor)
                              throws IOException
Throws:
IOException

singleInputStream

public static InputStream singleInputStream(String path,
                                            ResourceAccessor resourceAccessor)
                                     throws IOException
Throws:
IOException


Copyright © 2016 Liquibase.org. All rights reserved.