public class FileInputStream extends InputStream {
- private int fd;
+ private int fd;
- public FileInputStream(String pathname) {
- fd=nativeOpen(pathname.getBytes());
- }
+ public FileInputStream(String pathname) {
+ fd=nativeOpen(pathname.getBytes());
+ }
- public FileInputStream(File path) {
- fd=nativeOpen(path.getPath().getBytes());
- }
- public int getfd() {
- return fd;
- }
+ public FileInputStream(File path) {
+ fd=nativeOpen(path.getPath().getBytes());
+ }
+ public int getfd() {
+ return fd;
+ }
- private static native int nativeOpen(byte[] filename);
- private static native int nativeRead(int fd, byte[] array, int numBytes);
- private static native void nativeClose(int fd);
-
- public int read() {
- byte b[]=new byte[1];
- int retval=read(b);
- if (retval==-1)
- return -1;
- return b[0];
- }
+ private static native int nativeOpen(byte[] filename);
+ private static native int nativeRead(int fd, byte[] array, int numBytes);
+ private static native void nativeClose(int fd);
- public int read(byte[] b) {
- return nativeRead(fd, b, b.length);
- }
+ public int read() {
+ byte b[]=new byte[1];
+ int retval=read(b);
+ if (retval==-1)
+ return -1;
+ return b[0];
+ }
- public void close() {
- nativeClose(fd);
- }
+ public int read(byte[] b) {
+ return nativeRead(fd, b, b.length);
+ }
+
+ public void close() {
+ nativeClose(fd);
+ }
}