net.aerith.misao.io
Class Decoder

java.lang.Object
  |
  +--net.aerith.misao.io.Decoder

public class Decoder
extends java.lang.Object

The Decoder is a class to decode a file in some compression or cryption. In general, it unzips the file automatically when the file name ends with .gz.


Constructor Summary
Decoder()
           
 
Method Summary
static java.lang.String[] getCompressedExtensions()
          Returns the list of supported file extensions of compressed files.
static java.io.File newFile(java.lang.String path)
          Creates a new file object for the specified path.
static java.io.DataInputStream newInputStream(java.io.File file)
          Creates a new input stream.
private static java.io.InputStream newInputStream(java.lang.String name, java.io.InputStream stream)
          Creates a new input stream.
static java.io.DataInputStream newInputStream(java.net.URL url)
          Creates a new input stream.
static java.io.BufferedReader newReader(java.io.File file)
          Creates a new reader.
static java.io.BufferedReader newReader(java.net.URL url)
          Creates a new reader.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

Decoder

public Decoder()
Method Detail

getCompressedExtensions

public static final java.lang.String[] getCompressedExtensions()
Returns the list of supported file extensions of compressed files.
Returns:
the list of supported file extensions of compressed files.

newFile

public static final java.io.File newFile(java.lang.String path)
Creates a new file object for the specified path. If the file does not exists, it searches a file with ".gz" suffix, or a file without ".gz" suffix when it is already attached.
Parameters:
path - the path of a file.
Returns:
the file object.

newInputStream

public static final java.io.DataInputStream newInputStream(java.io.File file)
                                                    throws java.io.IOException,
                                                           java.io.FileNotFoundException
Creates a new input stream. When the file name ends with .gz, it automatically unzips.
Parameters:
file - the file.
Returns:
the input stream.
Throws:
java.io.IOException - if a file cannot be accessed.
java.io.FileNotFoundException - if a file does not exists.

newReader

public static final java.io.BufferedReader newReader(java.io.File file)
                                              throws java.io.IOException,
                                                     java.io.FileNotFoundException
Creates a new reader. When the file name ends with .gz, it automatically unzips.
Parameters:
file - the file.
Returns:
the reader.
Throws:
java.io.IOException - if a file cannot be accessed.
java.io.FileNotFoundException - if a file does not exists.

newInputStream

public static final java.io.DataInputStream newInputStream(java.net.URL url)
                                                    throws java.io.IOException
Creates a new input stream. When the file name ends with .gz, it automatically unzips.
Parameters:
url - the URL.
Returns:
the input stream.
Throws:
java.io.IOException - if a file cannot be accessed.

newReader

public static final java.io.BufferedReader newReader(java.net.URL url)
                                              throws java.io.IOException
Creates a new reader. When the file name ends with .gz, it automatically unzips.
Parameters:
url - the URL.
Returns:
the reader.
Throws:
java.io.IOException - if a file cannot be accessed.

newInputStream

private static final java.io.InputStream newInputStream(java.lang.String name,
                                                        java.io.InputStream stream)
                                                 throws java.io.IOException
Creates a new input stream. When the file name ends with .gz, it automatically unzips.
Parameters:
name - the name of the file or URL.
stream - the primitive input stream.
Returns:
the input stream.
Throws:
java.io.IOException - if a file cannot be accessed.