1 7 8 package java.io; 9 10 26 public final class FileDescriptor { 27 28 private int fd; 29 30 private long handle; 31 32 36 public FileDescriptor() { 37 fd = -1; 38 handle = -1; 39 } 40 41 private FileDescriptor(int fd) { 42 this.fd = fd; 43 handle = -1; 44 } 45 46 static { 47 initIDs(); 48 } 49 50 57 public static final FileDescriptor in = standardStream(0); 58 59 65 public static final FileDescriptor out = standardStream(1); 66 67 74 public static final FileDescriptor err = standardStream(2); 75 76 83 public boolean valid() { 84 return ((handle != -1) || (fd != -1)); 85 } 86 87 115 public native void sync() throws SyncFailedException ; 116 117 118 private static native void initIDs(); 119 120 private static native long set(int d); 121 122 private static FileDescriptor standardStream(int fd) { 123 FileDescriptor desc = new FileDescriptor (); 124 desc.handle = set(fd); 125 return desc; 126 } 127 128 } 129 | Popular Tags |