changes: now Inference engine works fine with the EyeTracking benchmark.
[IRC.git] / Robust / src / ClassLibrary / SSJava / FileOutputStream.java
1 //import java.io.FileDescriptor;
2 @LATTICE("FD")
3 public class FileOutputStream extends OutputStream {
4   @LOC("FD") private int fd;
5
6   public FileOutputStream(String pathname) {
7     fd=nativeOpen(pathname.getBytes());
8   }
9
10   public FileOutputStream(String pathname, boolean append) {
11     if(append)
12       fd=nativeAppend(pathname.getBytes());
13     else
14       fd=nativeOpen(pathname.getBytes());
15   }
16
17   public FileOutputStream(String pathname, int mode) {
18     if(mode==0)
19       fd=nativeAppend(pathname.getBytes());
20     if(mode==1)
21       fd=nativeOpen(pathname.getBytes());
22   }
23
24   public FileOutputStream(File path) {
25     fd=nativeOpen(path.getPath().getBytes());
26   }
27
28   public FileOutputStreamOpen(String pathname) {
29     fd = nativeOpen(pathname.getBytes());
30   }
31
32   public FileOutputStream(FileDescriptor fdObj) {
33     fd = nativeOpen(fdObj.channel.getBytes());
34   }
35
36   private static native int nativeOpen(byte[] filename);
37   private static native int nativeAppend(byte[] filename);
38   private static native void nativeWrite(int fd, byte[] array, int off, int len);
39   private static native void nativeClose(int fd);
40   private static native void nativeFlush(int fd);
41
42   public void write(int ch) {
43     byte b[]=new byte[1];
44     b[0]=(byte)ch;
45     write(b);
46   }
47
48   public void write(byte[] b) {
49     nativeWrite(fd, b, 0, b.length);
50   }
51
52   public void write(byte[] b, int index, int len) {
53     nativeWrite(fd, b, index, len);
54   }
55
56   public void flush() {
57     nativeFlush(fd);
58   }
59
60   public void close() {
61     nativeClose(fd);
62   }
63 }