org.clazzes.jdbc2xml.helper
Class StreamHelper

java.lang.Object
  extended by org.clazzes.jdbc2xml.helper.StreamHelper

public abstract class StreamHelper
extends Object

Static functions for setting up compressed/uncompressed streams.

Author:
wglas

Constructor Summary
StreamHelper()
           
 
Method Summary
static InputStream makeInputStream(String filename)
          Creates an input stream, which possibly does decompression based on the extension of the given filename.
static OutputStream makeOutpuStream(String filename, Integer compression)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamHelper

public StreamHelper()
Method Detail

makeInputStream

public static InputStream makeInputStream(String filename)
                                   throws IOException
Creates an input stream, which possibly does decompression based on the extension of the given filename.

Parameters:
filename - The name of the file to open.
Returns:
A GZIPInputStream, if the filename ends with .gz, a BZip2InputStream, if the filename ends with .bz2, System.in if filename is null or a bare FileInputStream in all other situations.
Throws:
IOException - If the file does not exist or the headers of compressed file are invalid.

makeOutpuStream

public static OutputStream makeOutpuStream(String filename,
                                           Integer compression)
                                    throws IOException
Throws:
IOException


Copyright © 2012. All Rights Reserved.