javatools.test
Class NewUTF8Reader

java.lang.Object
  extended by java.io.Reader
      extended by javatools.test.NewUTF8Reader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class NewUTF8Reader
extends java.io.Reader

This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools). It is licensed under the Creative Commons Attribution License (see http://creativecommons.org/licenses/by/3.0) by the YAGO-NAGA team (see http://mpii.de/yago-naga). This class can read characters from a file that is UTF8 encoded.
Example:

 Reader f=new UTF8Reader(new File("blah.blb"));
 int c;
 while((c=f.read())!=-1) System.out.print(Char.normalize(c));
 f.close();
 


Constructor Summary
NewUTF8Reader(java.io.File f)
          Constructs a UTF8Reader from a File
NewUTF8Reader(java.io.File f, java.lang.String message)
          Constructs a UTF8Reader from a File, makes a nice progress bar, but reads slower, 1GB in 18 seconds with progressbar, 11 seconds without
NewUTF8Reader(java.io.InputStream s)
          Constructs a UTF8Reader from a Reader
NewUTF8Reader(java.lang.String f)
          Constructs a UTF8Reader from a File
NewUTF8Reader(java.lang.String f, java.lang.String message)
          Constructs a UTF8Reader from a File, makes a nice progress bar, but reads slower, 1GB in 18 seconds with progressbar, 11 seconds without
NewUTF8Reader(java.net.URL url)
          Constructs a UTF8Reader for an URL
 
Method Summary
 void close()
           
static void main(java.lang.String[] args)
          Test method
 long numBytesRead()
          Returns the number of bytes read from the underlying stream
 int read()
           
 int read(char[] cbuf, int off, int len)
           
 java.lang.String readLine()
          Reads a line do not between read() and readLine methods pick one and stick to it.
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NewUTF8Reader

public NewUTF8Reader(java.io.InputStream s)
Constructs a UTF8Reader from a Reader


NewUTF8Reader

public NewUTF8Reader(java.net.URL url)
              throws java.io.IOException
Constructs a UTF8Reader for an URL

Throws:
java.io.IOException

NewUTF8Reader

public NewUTF8Reader(java.io.File f)
              throws java.io.FileNotFoundException
Constructs a UTF8Reader from a File

Throws:
java.io.FileNotFoundException

NewUTF8Reader

public NewUTF8Reader(java.io.File f,
                     java.lang.String message)
              throws java.io.FileNotFoundException
Constructs a UTF8Reader from a File, makes a nice progress bar, but reads slower, 1GB in 18 seconds with progressbar, 11 seconds without

Throws:
java.io.FileNotFoundException

NewUTF8Reader

public NewUTF8Reader(java.lang.String f)
              throws java.io.FileNotFoundException
Constructs a UTF8Reader from a File

Throws:
java.io.FileNotFoundException

NewUTF8Reader

public NewUTF8Reader(java.lang.String f,
                     java.lang.String message)
              throws java.io.FileNotFoundException
Constructs a UTF8Reader from a File, makes a nice progress bar, but reads slower, 1GB in 18 seconds with progressbar, 11 seconds without

Throws:
java.io.FileNotFoundException
Method Detail

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
Specified by:
read in class java.io.Reader
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.Reader
Throws:
java.io.IOException

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Reads a line do not between read() and readLine methods pick one and stick to it.

Throws:
java.io.IOException

numBytesRead

public long numBytesRead()
Returns the number of bytes read from the underlying stream


main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Test method

Throws:
java.io.IOException