public void testFile() throws Exception
{
File file = new File(ClassLoader.getSystemResource("normal.html").getFile());
assertEquals(true, file.exists());
FileInputStream input = new FileInputStream(file);
BufferedInputStream buffer = new BufferedInputStream(input);
byte[] data = new byte[buffer.available()];
int available = -1;
Detector det = new Detector(PSMDetector.ALL);
//Set an observer...
//The Notify() will be called when a matching charset is found.
det.init(new ICharsetDetectionObserver()
{
public void notify(String charset)
{
System.out.println("CHARSET === " + charset);
}
});
boolean done = false;
boolean isAscii = true;
while ((available = buffer.read(data)) > -1)
{
//Khoilv'code.
//System.out.print(data);
if (isAscii)
isAscii = det.isAscii(data, available);