1 /*************************************************************************
2 /* FileReaderTest.java -- Test of FileReader and InputStreamReader classes
4 /* Copyright (c) 1998 Free Software Foundation, Inc.
5 /* Written by Aaron M. Renn (arenn@urbanophile.com)
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 /*************************************************************************/
24 public class FileReaderTest
30 System
.out
.println("Starting test of FileReader and InputStreamReader");
32 System
.out
.println("Test 1: File Read Test");
35 FileReader fr
= new FileReader("/etc/services");
37 System
.out
.println("Dumping file. Note that first 100 bytes will be skipped");
40 char[] buf
= new char[32];
43 while((chars_read
= fr
.read(buf
)) != -1)
44 System
.out
.print(new String(buf
, 0, chars_read
));
47 System
.out
.println("PASSED: File read test");
51 System
.out
.println("FAILED: File read test: " + e
);
54 System
.out
.println("Test 2: File Not Found Test");
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