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/] [FileOutputStreamTest.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/*************************************************************************
2
/* FileOutputStreamTest.java -- Test of FileOutputStream class
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 FileOutputStreamTest
25
{
26
 
27
public static void
28
main(String[] argv)
29
{
30
  System.out.println("Starting test of FileOutputStream");
31
 
32
  System.out.println("Test 1: File Write Test");
33
  try
34
    {
35
      String s1 = "Ok, what are some of the great flame wars that we have " +
36
         "had lately.  Let us see, there was emacs vs. xemacs, " +
37
         "KDE vs. Gnome, and Tcl vs. Guile";
38
 
39
      String s2 = "Operating systems I have known include: solaris, sco, " +
40
         "hp-ux, linux, freebsd, winblows, os400, mvs, tpf, its, multics";
41
 
42
      //File f = File.createTempFile("fostest", new File("/tmp"));
43
      File f = new File("/tmp/000000");
44
      FileOutputStream fos = new FileOutputStream(f.getPath());
45
 
46
      fos.write(s1.getBytes(), 0, 32);
47
      fos.write(s1.getBytes(), 32, s1.getBytes().length - 32);
48
      fos.close();
49
 
50
      fos = new FileOutputStream(f.getPath(), true);
51
      fos.write(s2.getBytes());
52
      fos.close();
53
 
54
      if (f.length() != (s1.length() + s2.length()))
55
        throw new IOException("Incorrect number of bytes written");
56
 
57
      f.delete();
58
 
59
      System.out.println("PASSED: File Write Test");
60
    }
61
  catch(IOException e)
62
    {
63
      System.out.println("FAILED: File Write Test: " + e);
64
    }
65
 
66
  System.out.println("Test 2: Permission Denied Test");
67
  try
68
    {
69
      FileOutputStream fos = new FileOutputStream("/etc/newtempfile");
70
      System.out.println("FAILED: Permission Denied Test");
71
    }
72
  catch (IOException e)
73
    {
74
      System.out.println("PASSED: Permission Denied Test: " + e);
75
    }
76
 
77
  System.out.println("Finished test of FileOutputStream");
78
}
79
 
80
} // class FileOutputStreamTest
81
 

powered by: WebSVN 2.1.0

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