package de.vdheide.io;

import java.io.*;
import de.vdheide.io.RandomAccess;

/**
 * A wrapper for RandomAccessFile. As this wrapper implements RandomAccess, both
 * this wrapper (and therefore RandomAccessFile) and RandomAccesssByteArray may
 * be used in the same method signature.
 *
 * @author Jens Vonderheide <jvonderheide@redlink.de>
 */
public class RandomAccessFileWrapper implements RandomAccess {

	public RandomAccessFileWrapper(File file, String mode) throws FileNotFoundException {
		this.raf = new RandomAccessFile(file, mode);
	}
	
	public RandomAccessFileWrapper(String name, String mode) throws FileNotFoundException {
		this.raf = new RandomAccessFile(name, mode);
	}

	public int read() throws IOException {
		return raf.read();
	}
	
	public int read(byte b[], int off, int len) throws IOException {
		return raf.read(b, off, len);
	}
	
	public int readUnsignedByte() throws IOException {
		return raf.readUnsignedByte();
	}
	
	public void seek(long n) throws IOException {
		raf.seek(n);
	}
	
	public long getPointer() throws IOException {
		return raf.getFilePointer();
	}
	
	public void close() throws IOException {
		raf.close();
	}
	
	public long length() throws IOException {
		return raf.length();
	}
	
	protected RandomAccessFile raf;
	
}
