1 /* Copyright (C) 1998, 1999 Cygnus Solutions
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
12 * @author Warren Levy <warrenl@cygnus.com>
13 * @date October 28, 1998.
15 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
16 * "The Java Language Specification", ISBN 0-201-63451-1
17 * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
18 * Status: Believed complete and correct.
21 public class FileInputStream extends InputStream
23 /* Contains the file descriptor for referencing the actual file. */
24 private FileDescriptor fd;
26 public FileInputStream(String name) throws FileNotFoundException, IOException
28 SecurityManager s = System.getSecurityManager();
31 fd = new FileDescriptor(name, FileDescriptor.READ);
34 public FileInputStream(File file) throws FileNotFoundException, IOException
39 public FileInputStream(FileDescriptor fdObj)
41 SecurityManager s = System.getSecurityManager();
47 public int available() throws IOException
49 return fd.available();
52 public void close() throws IOException
61 protected void finalize() throws IOException
67 public final FileDescriptor getFD() throws IOException
70 throw new IOException();
74 public int read() throws IOException
79 public int read(byte[] b) throws IOException
81 return fd.read(b, 0, b.length);
84 public int read(byte[] b, int off, int len) throws IOException
86 if (off < 0 || len < 0 || off + len > b.length)
87 throw new ArrayIndexOutOfBoundsException();
89 return fd.read(b, off, len);
92 public long skip(long n) throws IOException
94 return fd.seek(n, FileDescriptor.CUR);