JReader.java



import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.IOException;

/** 日本語のファイルを読み込み、標準出力に表示する JReader */

public class JReader {

    /** バッファサイズ(2バイト単位) */

       public static final int BUFSIZE = 512;

    /** 最初に呼び出される処理 */

       public static void main( String argv[] ) {

              FileReader fr;

              if( argv.length == 1 ) {
                      try {
                             fr = new FileReader( argv[0] );

                             char[] buf = new char[BUFSIZE];
                             int c;
                             while( ( c = fr.read( buf, 0, BUFSIZE ) ) != -1 ) {
                                 System.out.print( new String( buf ) );
                              }
                      }
                      catch( FileNotFoundException e ){
                             System.out.println( "File "
                                             + argv[0] + " Not Found" );
                      }
                      catch( IOException e ){
                             System.out.println( "IO Error..." );
                      }
               }
       }
}