Support for reading/writing files via FileInputStream and FileOutputStream.java classes.
[IRC.git] / Robust / src / ClassLibrary / FileInputStream.java
1 public class FileInputStream {
2     private int fd;
3
4     public FileInputStream(String pathname) {
5         fd=nativeOpen(pathname.getBytes());
6     }
7
8     private static native int nativeOpen(byte[] filename);
9     private static native int nativeRead(int fd, byte[] array, int numBytes);
10     private static native void nativeClose(int fd);
11     
12     public int read() {
13         byte b[]=new byte[1];
14         int retval=read(b);
15         if (retval==-1)
16             return -1;
17         return b[0];
18     }
19
20     public int read(byte[] b) {
21         return nativeRead(fd, b, b.length);
22     }
23
24     public void close() {
25         nativeClose(fd);
26     }
27 }