01: package org.jgroups.util;
02:
03: import org.apache.commons.logging.Log;
04: import org.apache.commons.logging.LogFactory;
05:
06: import java.io.BufferedInputStream;
07: import java.io.InputStream;
08:
09: /**
10: * @author Bela Ban
11: * @version $Id: ExposedBufferedInputStream.java,v 1.3 2005/07/25 16:57:31 belaban Exp $
12: */
13: public class ExposedBufferedInputStream extends BufferedInputStream {
14: private final static Log log = LogFactory
15: .getLog(ExposedBufferedInputStream.class);
16:
17: /**
18: * Creates a <code>BufferedInputStream</code>
19: * and saves its argument, the input stream
20: * <code>in</code>, for later use. An internal
21: * buffer array is created and stored in <code>buf</code>.
22: *
23: * @param in the underlying input stream.
24: */
25: public ExposedBufferedInputStream(InputStream in) {
26: super (in);
27: }
28:
29: /**
30: * Creates a <code>BufferedInputStream</code>
31: * with the specified buffer size,
32: * and saves its argument, the input stream
33: * <code>in</code>, for later use. An internal
34: * buffer array of length <code>size</code>
35: * is created and stored in <code>buf</code>.
36: *
37: * @param in the underlying input stream.
38: * @param size the buffer size.
39: * @throws IllegalArgumentException if size <= 0.
40: */
41: public ExposedBufferedInputStream(InputStream in, int size) {
42: super (in, size);
43: }
44:
45: public void reset(int size) {
46: count = pos = marklimit = 0;
47: markpos = -1;
48: if (buf != null) {
49: if (size > buf.length) {
50: buf = new byte[size];
51: }
52: } else {
53: buf = new byte[4096];
54: if (log.isWarnEnabled())
55: log
56: .warn("output stream was closed, re-creating it (please don't close it)");
57: }
58: }
59: }
|