001:import java.io.FileReader;
002:import java.io.FileNotFoundException;
003:import java.io.IOException;
004:
005:public class First10Characters {
006: public static void main(String[] args) {
007: try {
008: FileReader reader =
009: new FileReader("First10Characters.java");
010: for(int i=0; i<10; i++) {
011: int c = reader.read();
012: if(c<0) break;
013: System.out.print((char)c);
014: }
015: reader.close();
016: System.out.println("");
017: } catch(FileNotFoundException e) {
018: System.out.println("ファイルがありません");
019: } catch(IOException e) {
020: System.out.println("入出力エラーです");
021: }
022: }
023:}