1 package org.xwt.mips.util;
5 public class SeekableFile implements SeekableData {
6 private final RandomAccessFile raf;
8 public SeekableFile(String fileName, boolean writable) throws IOException { this(new File(fileName),writable); }
10 public SeekableFile(File file, boolean writable) throws IOException {
11 raf = new RandomAccessFile(file,writable ? "rw" : "r");
14 public int read(byte[] buf, int offset, int length) throws IOException { return raf.read(buf,offset,length); }
15 public int write(byte[] buf, int offset, int length) throws IOException { raf.write(buf,offset,length); return length; }
16 public void seek(int pos) throws IOException{ raf.seek(pos); }
17 public int pos() throws IOException { return (int) raf.getFilePointer(); }
18 public int length() throws IOException { return (int)raf.length(); }
19 public void close() throws IOException { raf.close(); }