org.jtool.jxplatform.io
Class DetectCharset

java.lang.Object
  extended byorg.jtool.jxplatform.io.DetectCharset

public class DetectCharset
extends java.lang.Object

Detects charset names of input files.

Author:
Katsuhisa Maruyama

Constructor Summary
DetectCharset()
           
 
Method Summary
static java.lang.String getCharsetName(byte[] contents)
          Guesses the charset name of a Japanese text.
static java.lang.String getCharsetName(java.lang.String filename)
          Guesses the charset name of a Japanese text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DetectCharset

public DetectCharset()
Method Detail

getCharsetName

public static java.lang.String getCharsetName(java.lang.String filename)
                                       throws java.io.IOException
Guesses the charset name of a Japanese text.

Parameters:
filename - The name of a file.
Returns:
A charset name (US-ASCII, UTF-8, ISO-2022-JP, EUC-JP, or Shift_JIS).
Throws:
java.io.IOException - if an I/O error occurred.

getCharsetName

public static java.lang.String getCharsetName(byte[] contents)
                                       throws java.io.IOException
Guesses the charset name of a Japanese text.

Parameters:
contents - The contents of a file.
Returns:
A charset name (US-ASCII, UTF-8, ISO-2022-JP, EUC-JP, or Shift_JIS).
Throws:
java.io.IOException - if an I/O error occurred.