1 import java.io.FileDescriptor;
3 public class FileOutputStream extends OutputStream {
6 public FileOutputStream(String pathname) {
7 fd=nativeOpen(pathname.getBytes());
10 public FileOutputStream(String pathname, boolean append) {
12 fd=nativeAppend(pathname.getBytes());
14 fd=nativeOpen(pathname.getBytes());
17 public FileOutputStream(String pathname, int mode) {
19 fd=nativeAppend(pathname.getBytes());
21 fd=nativeOpen(pathname.getBytes());
24 public FileOutputStream(File path) {
25 fd=nativeOpen(path.getPath().getBytes());
28 public FileOutputStreamOpen(String pathname) {
29 fd = nativeOpen(pathname.getBytes());
32 public FileOutputStream(FileDescriptor fdObj) {
33 fd = nativeOpen(fdObj.channel.getBytes());
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);
42 public void write(int ch) {
48 public void write(byte[] b) {
49 nativeWrite(fd, b, 0, b.length);
52 public void write(byte[] b, int index, int len) {
53 nativeWrite(fd, b, index, len);