01: package uk.org.ponder.streamutil;
02:
03: import java.io.RandomAccessFile;
04: import java.io.File;
05: import java.io.IOException;
06:
07: /** This class wraps a <code>java.io.RandomAccessFile</code> object so that it
08: * conforms to the <code>RandomAccessWrite</code> interface.
09: */
10:
11: public class RandomAccessWriteWrapper extends RandomAccessReadWrapper
12: implements RandomAccessWrite {
13:
14: /** Constructs a RandomAccessWriteWrapper wrapping the supplied RandomAccessFile.
15: * @param internalraf The RandomAccessFile to be wrapped.
16: */
17:
18: public RandomAccessWriteWrapper(RandomAccessFile internalraf) {
19: super (internalraf);
20: }
21:
22: /** Constructs a RandomAccessFile from the supplied File object, and then
23: * wraps it with a RandomAccessWriteWrapper.
24: * @param file A file to be opened as a RandomAccessFile and wrapped.
25: */
26:
27: public RandomAccessWriteWrapper(File file) throws IOException {
28: internalraf = new RandomAccessFile(file, "rw");
29: }
30:
31: /** Constructs a RandomAccessFile for the specified filename, and then
32: * wraps it with a RandomAccessWriteWrapper.
33: * @param filename A file to be opened as a RandomAccessFile and wrapped.
34: */
35:
36: public RandomAccessWriteWrapper(String filename) throws IOException {
37: internalraf = new RandomAccessFile(filename, "rw");
38: }
39:
40: public void write(int b) throws IOException {
41: internalraf.write(b);
42: }
43:
44: public void write(byte b[], int off, int len) throws IOException {
45: internalraf.write(b, off, len);
46: }
47:
48: }
|