1 /* Copyright (C) 2003 Internet Archive.
2 *
3 * This file is part of the Heritrix web crawler (crawler.archive.org).
4 *
5 * Heritrix is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser Public License as published by
7 * the Free Software Foundation; either version 2.1 of the License, or
8 * any later version.
9 *
10 * Heritrix is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser Public License
16 * along with Heritrix; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * RandomAccessOutputStream.java
20 * Created on May 21, 2004
21 *
22 * $Header$
23 */
24 package org.archive.io;
25
26 import java.io.IOException;
27 import java.io.OutputStream;
28 import java.io.RandomAccessFile;
29
30
31 /***
32 * Wraps a RandomAccessFile with OutputStream interface.
33 *
34 * @author gojomo
35 */
36 public class RandomAccessOutputStream extends OutputStream {
37 RandomAccessFile raf;
38
39 /***
40 * Wrap the given RandomAccessFile
41 */
42 public RandomAccessOutputStream(RandomAccessFile raf) {
43 super();
44 this.raf = raf;
45 }
46
47 /* (non-Javadoc)
48 * @see java.io.OutputStream#write(int)
49 */
50 public void write(int b) throws IOException {
51 raf.write(b);
52 }
53
54 /* (non-Javadoc)
55 * @see java.io.OutputStream#close()
56 */
57 public void close() throws IOException {
58 raf.close();
59 }
60
61 /* (non-Javadoc)
62 * @see java.io.OutputStream#write(byte[], int, int)
63 */
64 public void write(byte[] b, int off, int len) throws IOException {
65 raf.write(b, off, len);
66 }
67
68 /* (non-Javadoc)
69 * @see java.io.OutputStream#write(byte[])
70 */
71 public void write(byte[] b) throws IOException {
72 raf.write(b);
73 }
74 }