initial checkin
[org.ibex.nanogoat.git] / upstream / mips / org / xwt / mips / util / SeekableFile.java
1 package org.xwt.mips.util;
2
3 import java.io.*;
4
5 public class SeekableFile implements SeekableData {
6     private final RandomAccessFile raf;
7     
8     public SeekableFile(String fileName, boolean writable) throws IOException { this(new File(fileName),writable); }    
9     
10     public SeekableFile(File file, boolean writable) throws IOException {
11         raf = new RandomAccessFile(file,writable ? "rw" : "r");
12     }
13     
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(); }
20 }