add more comments
[IRC.git] / Robust / src / ClassLibrary / FileOutputStream.java
1 public class FileOutputStream {
2     private int fd;
3
4     public FileOutputStream(String pathname) {
5         fd=nativeOpen(pathname.getBytes());
6     }
7
8     public FileOutputStream(String pathname, int mode) {
9         if(mode==0)     
10                 fd=nativeAppend(pathname.getBytes());
11         if(mode==1)
12                 fd=nativeOpen(pathname.getBytes());
13     }
14
15
16     public FileOutputStream(File path) {
17         fd=nativeOpen(path.getPath().getBytes());
18     }
19
20     private static native int nativeOpen(byte[] filename);
21     private static native int nativeAppend(byte[] filename);
22     private static native void nativeWrite(int fd, byte[] array);
23     private static native void nativeClose(int fd);
24     private static native void nativeFlush(int fd);
25     
26     public void write(int ch) {
27         byte b[]=new byte[1];
28         b[0]=(byte)ch;
29         write(b);
30     }
31
32     public void write(byte[] b) {
33         nativeWrite(fd, b);
34     }
35
36     public void flush() {
37         nativeFlush(fd);
38     }
39
40     public void close() {
41         nativeClose(fd);
42     }
43 }