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


// @(#)RAFOutputStream.java, 1.6, 10/28/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.6, 10/28/96


 */


public class RAFOutputStream extends OutputStream {


    RandomAccessFile raf;





    public RAFOutputStream(String path) throws IOException {


	this(new File(path));


    }





    public RAFOutputStream(File file) throws IOException {


	this(new RandomAccessFile(file, "rw"));


    }





    public RAFOutputStream(RandomAccessFile raf) {


	this.raf = raf;


    }





    public void write(int b) throws IOException {


	raf.write(b);


    }





    public void write(byte b[]) throws IOException {


	raf.write(b, 0, b.length);


    }





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


	raf.write(b, off, len);


    }





    /* random access files are not buffered */


    public void flush() throws IOException {


    }





    public void close() throws IOException {


	raf.close();


    }





    public void seek(long pos) throws IOException {


	raf.seek(pos);


    }





    public RandomAccessFile getRAF() {


	return raf;


    }


}


