Skip navigation links


com.essbase.eas.utils
Class TextFile

java.lang.Object
  extended by com.essbase.eas.utils.TextFile

Direct Known Subclasses:
EssbaseTextFile

public class TextFile
extends java.lang.Object

Field Summary
protected  short encoding
           
protected  java.io.File file
           
protected  java.lang.String locale
           
static short NATIVE
           
static short NATIVE_WITH_LOCALE
           
static short UNKNOWN
           
static short UTF8
           
static byte[] UTF8Bytes
           
static java.lang.String UTF8Charset
           

 

Constructor Summary
TextFile(java.io.File _file)
           

 

Method Summary
 java.lang.String getCharset(java.lang.String locale)
          override this to support character set
 short getEncoding()
           
static short getEncoding(java.io.File file, byte[] bytes)
          Get the encoding of the file
 java.io.File getFile()
           
static TextFileReader getFileReader(java.io.File file, short encoding, java.lang.String charset)
           
static TextFileReader getFileReader(java.io.File file, java.lang.String charset)
           
 java.lang.String getLocale()
           
static java.lang.String getString(byte[] bytes)
          Returns string equivalent on the specified bytes based on the encoding of the input bytes
static boolean hasUTF8Signature(byte[] _bytes)
          Checks specified bytes to see if it has leading UTF-8 signature
static boolean hasUTF8Signature(java.io.InputStream inp)
           
 boolean isEncodingUTF8()
           
static boolean isFileUTF8(java.io.File file)
          check to see if the file is of UTF8 format
 java.lang.String readFile()
          Reads a file
static java.util.List readFileAsList(java.io.File file, java.lang.String charset)
          Reads the file as a list of strings
protected  void readWithEncoding(byte[] bytes)
          Sets the encoding of the file
 void setEncoding(short _encoding)
           
 void setFile(java.io.File _file)
           
 void setLocale(java.lang.String _locale)
           
static boolean writeFile(java.io.File file, java.lang.String _outStr, short encoding)
          Writes contents to a file
 boolean writeFile(java.lang.String _outStr)
          writes the file
static boolean writeFileWithHeader(java.io.File file, java.lang.String _outStr, short encoding, java.lang.String charset)
           
 boolean writeFileWithHeader(java.lang.String _outStr)
           
static void writeUTF8Signature(java.io.OutputStream stream)
           

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

NATIVE

public static final short NATIVE
See Also:
Constant Field Values

NATIVE_WITH_LOCALE

public static final short NATIVE_WITH_LOCALE
See Also:
Constant Field Values

UTF8

public static final short UTF8
See Also:
Constant Field Values

UNKNOWN

public static final short UNKNOWN
See Also:
Constant Field Values

UTF8Charset

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

UTF8Bytes

public static final byte[] UTF8Bytes

encoding

protected short encoding

file

protected java.io.File file

locale

protected java.lang.String locale

Constructor Detail

TextFile

public TextFile(java.io.File _file)

Method Detail

setEncoding

public void setEncoding(short _encoding)

getEncoding

public short getEncoding()

isEncodingUTF8

public boolean isEncodingUTF8()

setFile

public void setFile(java.io.File _file)

getFile

public java.io.File getFile()

setLocale

public void setLocale(java.lang.String _locale)

getLocale

public java.lang.String getLocale()

hasUTF8Signature

public static boolean hasUTF8Signature(byte[] _bytes)
Checks specified bytes to see if it has leading UTF-8 signature
Parameters:
_bytes - input bytes
Returns:
true if the specified bytes has leading UTF-8 signature false otherwise

hasUTF8Signature

public static boolean hasUTF8Signature(java.io.InputStream inp)
                                throws java.io.IOException
Throws:
java.io.IOException

getString

public static java.lang.String getString(byte[] bytes)
Returns string equivalent on the specified bytes based on the encoding of the input bytes
Parameters:
bytes - input bytes
Returns:
string equivalent of the input bytes

readWithEncoding

protected void readWithEncoding(byte[] bytes)
                         throws java.io.IOException
Sets the encoding of the file
Parameters:
bytes - byte buffer, can be null
Throws:
java.io.IOException

getEncoding

public static short getEncoding(java.io.File file,
                                byte[] bytes)
                         throws java.io.IOException
Get the encoding of the file
Parameters:
file - the input file
bytes - the byte buffer, can be null
Returns:
the encoding of the file
Throws:
java.io.IOException

isFileUTF8

public static boolean isFileUTF8(java.io.File file)
                          throws java.io.IOException
check to see if the file is of UTF8 format
Parameters:
file - the input file
Returns:
true if its UTF8
Throws:
java.io.IOException

readFile

public java.lang.String readFile()
Reads a file
Returns:
the contents of the file as string

writeFile

public boolean writeFile(java.lang.String _outStr)
writes the file
Parameters:
_outStr - the contents
Returns:
true if successful

writeFile

public static boolean writeFile(java.io.File file,
                                java.lang.String _outStr,
                                short encoding)
Writes contents to a file
Parameters:
file - file to be written
_outStr - the contents
encoding - encoding to use
Returns:
true if successful

getFileReader

public static TextFileReader getFileReader(java.io.File file,
                                           java.lang.String charset)

getFileReader

public static TextFileReader getFileReader(java.io.File file,
                                           short encoding,
                                           java.lang.String charset)

readFileAsList

public static java.util.List readFileAsList(java.io.File file,
                                            java.lang.String charset)
Reads the file as a list of strings
Parameters:
file - the input file
charset - the charset
Returns:
the list with the encoding

getCharset

public java.lang.String getCharset(java.lang.String locale)
override this to support character set
Parameters:
locale - locale
Returns:
the character set

writeFileWithHeader

public boolean writeFileWithHeader(java.lang.String _outStr)

writeFileWithHeader

public static boolean writeFileWithHeader(java.io.File file,
                                          java.lang.String _outStr,
                                          short encoding,
                                          java.lang.String charset)

writeUTF8Signature

public static void writeUTF8Signature(java.io.OutputStream stream)
                               throws java.io.IOException
Throws:
java.io.IOException

Skip navigation links


Copyright © 2001, 2012, Oracle. All rights reserved.