OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [test/] [java.io/] [FileReaderTest.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/*************************************************************************
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.
11
/*
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.
16
/*
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
/*************************************************************************/
21
 
22
import java.io.*;
23
 
24
public class FileReaderTest
25
{
26
 
27
public static void
28
main(String[] argv)
29
{
30
  System.out.println("Starting test of FileReader and InputStreamReader");
31
 
32
  System.out.println("Test 1: File Read Test");
33
  try
34
    {
35
      FileReader fr = new FileReader("/etc/services");
36
 
37
      System.out.println("Dumping file. Note that first 100 bytes will be skipped");
38
      fr.skip(100);
39
 
40
      char[] buf = new char[32];
41
      int chars_read = 0;
42
 
43
      while((chars_read = fr.read(buf)) != -1)
44
        System.out.print(new String(buf, 0, chars_read));
45
 
46
      fr.close();
47
      System.out.println("PASSED: File read test");
48
    }
49
  catch(IOException e)
50
    {
51
      System.out.println("FAILED: File read test: " + e);
52
    }
53
 
54
  System.out.println("Test 2: File Not Found Test");
55
  try
56
    {
57
      FileReader fr = new FileReader("/etc/yourmommasawhore");
58
      System.out.println("FAILED: File Not Found Test");
59
    }
60
  catch (FileNotFoundException e)
61
    {
62
      System.out.println("PASSED: File Not Found Test");
63
    }
64
 
65
  System.out.println("Finished test of FileReader");
66
}
67
 
68
} // class FileReaderTest
69
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.