// Copyright 1996, Marimba Inc. All Rights Reserved.


// @(#)RAFInputStream.java, 1.5, 08/14/96





package marimba.io;





import java.io.*;





/**


 * An output stream class which interfaces to a RandomAccessFile.


 * This is a way to open a file for appending.


 *


 * @author	Jonathan Payne


 * @version 	1.5, 08/14/96


 */


public class RAFInputStream extends InputStream {


    RandomAccessFile in;





    public RAFInputStream(RandomAccessFile in) {


	this.in = in;


    }





    public int read() throws IOException {


	return in.read();


    }





    public int read(byte b[]) throws IOException {


	int n = in.read(b, 0, b.length);


	return ((n <= 0) && (b.length > 0)) ? -1 : n;


    }





    public int read(byte b[], int off, int len) throws IOException {


	int n = in.read(b, off, len);


	return ((n <= 0) && (len > 0)) ? -1 : n;


    }





    public long skip(long n) throws IOException {


	return in.skipBytes((int) n);


    }





    public int available() throws IOException {


	return (int)(in.length() - in.getFilePointer());


    }





    public void close() throws IOException {


	in.close();


    }


}


