|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.mayo.bsi.ngsportal.server.Compressor
public class Compressor
Class that seamlessly handles reading and writing Zipped, Gzipped, and Bzipped files, using Java's built in code for dealing with Zipped files, and Apache's code for dealing with BZipped and Gzipped files. It does this by looking at the file suffix, returning a plain Buffered Reader / Writer if the file has a suffix that is not recognized as a compressed file.
| Field Summary | |
|---|---|
static int |
kBZipCompression
Signifies a file using BZip compression. |
static int |
kGZipCompression
Signifies a file using GZip compression. |
static int |
kNoCompression
Signifies an uncompressed file, or at least one whose compression we don't understand. |
static int |
kZipCompression
Signifies a file using Zip compression. |
| Constructor Summary | |
|---|---|
Compressor(File inFile,
File outFile)
|
|
Compressor(File inFile,
File outFile,
boolean append)
|
|
| Method Summary | |
|---|---|
static int |
compressionUsed(File testFile)
Static function to tell the caller if the file is / will be compressed |
int |
getCompression()
Accessor function to return the type of compression this file is using |
BufferedReader |
getReader()
|
static String |
getSuffix(File file)
Extract the suffix from the file name and return it |
static String |
getSuffix(int compression)
Return the suffix used by files with this type of compression, or an empty string if no compression. |
static String |
getSuffix(String name)
Extract the suffix from the name and return it |
BufferedWriter |
getWriter()
|
BufferedReader |
resetReader()
Routine to close the current reader, and get a new reader at the start of the file. |
void |
setInputStream(InputStream inStream,
String name)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int kNoCompression
public static final int kZipCompression
public static final int kGZipCompression
public static final int kBZipCompression
| Constructor Detail |
|---|
public Compressor(File inFile,
File outFile)
throws IOException
inFile - File to read from, that might be zip, bzip or gzip compressed, or nulloutFile - File to write to, that might be zip, bzip or gzip compressed, or null
IOException - if there's a problem building the file accessors
public Compressor(File inFile,
File outFile,
boolean append)
throws IOException
inFile - File to read from, that might be zip, bzip or gzip compressed, or nulloutFile - File to write to, that might be zip, bzip or gzip compressed, or nullappend - If true, then if writing to a non-compressed file will append data
to the file rather than overwriting it.
IOException - if there's a problem building the file accessors| Method Detail |
|---|
public void setInputStream(InputStream inStream,
String name)
inStream - Stream to read from, that might be zip, gzip or bzip compressedname - Name of the item behind the stream, so we can figure out the compressionpublic final BufferedReader getReader()
public final BufferedWriter getWriter()
public final int getCompression()
public static final int compressionUsed(File testFile)
testFile - File to test
public final BufferedReader resetReader()
throws IOException
IOExceptionpublic static final String getSuffix(int compression)
compression - type of compression
public static final String getSuffix(File file)
file - File to process
public static final String getSuffix(String name)
name - Name to process
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||