ariba.util.io
Class FileHandler

java.lang.Object
  extended by ariba.util.io.FileHandler

public class FileHandler
extends java.lang.Object

This class handles convertions between file byte streams and Unicode character streams, based of a file type. The encoding to be used is determined as follows. [Read] - The encoding passed as an argument, if specified and supported; - The encoding field embedded in the file, if exists and supported; - The encoding set by setSystemDefaultEncoding method, which is done by FileServer typically; - The default encoding of VM [Write] - The encoding passed as an argument, if specified and supported; - The encoding set by setSystemDefaultEncoding method, which is done by FileServer typically; - The default encoding of VM


Field Summary
static java.lang.String CHARSET_8859
           
static java.lang.String CHARSET_CP1252
           
static java.lang.String CHARSET_EUC_JP
           
static java.lang.String CHARSET_JIS
           
static java.lang.String CHARSET_SJIS
           
static java.lang.String NO_ENCODING
           
 
Method Summary
static java.lang.String getCSVFileEncodingCandidate(java.lang.String firstLine)
          Returns the first column in a comma separeted line that could be an encoding of the CSV file
static java.io.Reader getFile(java.io.File file, java.lang.String encoding)
          Returns a Reader associated with a file
static java.lang.String getFileExtension(java.io.File file)
          Returns an extension of the file
static java.lang.String getSystemDefaultEncoding()
          Returns system default encoding
static boolean isEncodingSupported(java.lang.String encoding)
          Checks if a specified encoding is supported by VM Typically this is used before saving a file, or for checking whether the first line of a CSV file is encoding information or not.
static java.io.Writer putFile(java.io.File file, java.lang.String encoding)
          Returns a Writer associated with a file
static void setSystemDefaultEncoding(java.lang.String encoding)
          Sets system default encoding Basically this is used by FileServer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHARSET_8859

public static final java.lang.String CHARSET_8859
See Also:
Constant Field Values

CHARSET_CP1252

public static final java.lang.String CHARSET_CP1252
See Also:
Constant Field Values

CHARSET_JIS

public static final java.lang.String CHARSET_JIS
See Also:
Constant Field Values

CHARSET_SJIS

public static final java.lang.String CHARSET_SJIS
See Also:
Constant Field Values

CHARSET_EUC_JP

public static final java.lang.String CHARSET_EUC_JP
See Also:
Constant Field Values

NO_ENCODING

public static final java.lang.String NO_ENCODING
See Also:
Constant Field Values
Method Detail

setSystemDefaultEncoding

public static void setSystemDefaultEncoding(java.lang.String encoding)
Sets system default encoding Basically this is used by FileServer

Parameters:
encoding - system default encoding

getSystemDefaultEncoding

public static java.lang.String getSystemDefaultEncoding()
Returns system default encoding


isEncodingSupported

public static boolean isEncodingSupported(java.lang.String encoding)
Checks if a specified encoding is supported by VM Typically this is used before saving a file, or for checking whether the first line of a CSV file is encoding information or not. It returns false when the encoding is null.

Parameters:
encoding - an encoding to be checked

getFile

public static java.io.Reader getFile(java.io.File file,
                                     java.lang.String encoding)
                              throws java.io.IOException
Returns a Reader associated with a file

Parameters:
file - a file to be read
encoding - an encoding that will be used If this is invalid, the encoding in the file is used if available. Otherwise the default is used, depending on the file type
Throws:
java.io.IOException

putFile

public static java.io.Writer putFile(java.io.File file,
                                     java.lang.String encoding)
                              throws java.io.IOException
Returns a Writer associated with a file

Parameters:
file - a file to be written
encoding - an encoding that will be used If this is invalid, the default is used, depending on the file type
Throws:
java.io.IOException

getFileExtension

public static java.lang.String getFileExtension(java.io.File file)
Returns an extension of the file

Parameters:
file - a file to be checked

getCSVFileEncodingCandidate

public static java.lang.String getCSVFileEncodingCandidate(java.lang.String firstLine)
Returns the first column in a comma separeted line that could be an encoding of the CSV file

Parameters:
firstLine - the first line of a CSV file


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.