KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ixenon > free > util > ReadbackStream


1 /* $Id$
2  *
3  * Copyright (c) 1999 Xenonsoft Limited. All Rights Reserved.
4  *
5  * This software is protected by copyright. You are hereby notified from
6  * now by reading this message. This software is also the confidential
7  * and proprietary information of Xenonsoft Limited. ("Confidential
8  * Information").
9  *
10  * This software is distributed under the Xenonsoft Public end user
11  * License ("XPeL"), where the machine-readable source code is provided
12  * under the "Open Source" model.
13  * For more information, please read the file "LICENSE-XPL.txt"
14  */

15
16 //
17
// DESCRIPTION
18
//
19
// Readback stream
20
// Fri Sep 11 01:29:18 BST 1998
21
//
22
// RCS HEADER ``ReadbackStream''
23
//
24
// $Author$
25
// $Date$
26
// $Source$
27
// $Revision$ $State$ $Locker$
28
//
29

30 package ixenon.free.util;
31
32 import java.io.*;
33
34 /**
35 * A pseudostream that can be written and then read back.
36 * It is currently implemented using ByteOutputStream and ByteInputStream
37 * This limits its usability for files which can fit wholly into
38 * the virtual memory.
39 * The implementation could be rewritten later to use temporary files.
40 */

41
42 public class ReadbackStream extends ByteArrayOutputStream
43 {
44     /**
45      * Creates a readback Stream
46      */

47     public ReadbackStream()
48     {
49     }
50     
51     /**
52      * Creates a readback Stream with an initial buffer length
53      * @param size initial buffer length in bytes
54      */

55     public ReadbackStream(int size)
56     {
57     super(size);
58     }
59
60     /**
61     * Returns an InputStream that can be used to read back
62     * what was written to this stream
63     */

64     public InputStream getInputStream()
65     {
66     return new ByteArrayInputStream(buf, 0, count);
67     }
68 }
69
70 // fini
71
Popular Tags