Dead
[official-gcc.git] / gomp-20050608-branch / libjava / classpath / test / java.io / FileReaderTest.java
blobe22cec53e72f65e4d1ff2a1b82253cad8e10b2a6
1 /*************************************************************************
2 /* FileReaderTest.java -- Test of FileReader and InputStreamReader classes
3 /*
4 /* Copyright (c) 1998 Free Software Foundation, Inc.
5 /* Written by Aaron M. Renn (arenn@urbanophile.com)
6 /*
7 /* This program is free software; you can redistribute it and/or modify
8 /* it under the terms of the GNU General Public License as published
9 /* by the Free Software Foundation, either version 2 of the License, or
10 /* (at your option) any later version.
12 /* This program is distributed in the hope that it will be useful, but
13 /* WITHOUT ANY WARRANTY; without even the implied warranty of
14 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 /* GNU General Public License for more details.
17 /* You should have received a copy of the GNU General Public License
18 /* along with this program; if not, write to the Free Software Foundation
19 /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 /*************************************************************************/
22 import java.io.*;
24 public class FileReaderTest
27 public static void
28 main(String[] argv)
30 System.out.println("Starting test of FileReader and InputStreamReader");
32 System.out.println("Test 1: File Read Test");
33 try
35 FileReader fr = new FileReader("/etc/services");
37 System.out.println("Dumping file. Note that first 100 bytes will be skipped");
38 fr.skip(100);
40 char[] buf = new char[32];
41 int chars_read = 0;
43 while((chars_read = fr.read(buf)) != -1)
44 System.out.print(new String(buf, 0, chars_read));
46 fr.close();
47 System.out.println("PASSED: File read test");
49 catch(IOException e)
51 System.out.println("FAILED: File read test: " + e);
54 System.out.println("Test 2: File Not Found Test");
55 try
57 FileReader fr = new FileReader("/etc/yourmommasawhore");
58 System.out.println("FAILED: File Not Found Test");
60 catch (FileNotFoundException e)
62 System.out.println("PASSED: File Not Found Test");
65 System.out.println("Finished test of FileReader");
68 } // class FileReaderTest