KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > blob > BLOBOutputStream


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: BLOBOutputStream.java,v 1.3 2002/12/29 11:15:55 per_nyfelt Exp $
8

9 package org.ozoneDB.blob;
10
11 import java.io.*;
12
13
14 /**
15  * The output stream of ozone BLOBs. Every write operations will call
16  * the underlaying BLOBContainer. Therefore BLOBStreams should never be used
17  * without buffering/caching. This can be done by using the BLOBStream together
18  * with a BufferedStream.
19  *
20  *
21  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
22  * @version $Revision: 1.3 $Date: 2002/12/29 11:15:55 $
23  */

24 public class BLOBOutputStream extends OutputStream implements Serializable {
25     
26     BLOBContainer container;
27     int index = 0;
28     
29     
30     public BLOBOutputStream( BLOBContainer _container ) {
31         container = _container;
32     }
33     
34     
35     public void write( byte[] b ) throws IOException {
36         write( b, 0, b.length );
37     }
38     
39     
40     public void write( byte[] b, int off, int len ) throws IOException {
41         try {
42             container.write( index, b, off, len );
43             index += len;
44         } catch (Exception JavaDoc e) {
45             e.printStackTrace();
46             throw new IOException( e.getMessage() );
47         }
48     }
49     
50     
51     public void write( int b ) throws IOException {
52         byte[] bb = new byte[1];
53         bb[0] = (byte)b;
54         write( bb, 0, 1 );
55     }
56     
57     
58     public void flush() throws IOException {
59     }
60     
61     
62     public void close() throws IOException {
63     }
64 }
65
Popular Tags