1 /*
2 * Copyright (C) The Apache Software Foundation. All rights reserved.
3 *
4 * This software is published under the terms of the Apache Software License
5 * version 1.1, a copy of which has been included with this distribution in
6 * the LICENSE file.
7 */
8 package org.apache.james.util;
9
10 import java.io.IOException;
11 import java.io.InputStream;
12
13 /***
14 * Reads data off a stream, printing every byte read to System.err.
15 */
16 public class DebugInputStream extends InputStream {
17
18 /***
19 * The input stream being wrapped
20 */
21 InputStream in = null;
22
23 /***
24 * Constructor that takes an InputStream to be wrapped.
25 *
26 * @param in the InputStream to be wrapped
27 */
28 public DebugInputStream(InputStream in) {
29 this.in = in;
30 }
31
32 /***
33 * Read a byte off the stream
34 *
35 * @return the byte read off the stream
36 * @throws IOException if an exception is encountered when reading
37 */
38 public int read() throws IOException {
39 int b = in.read();
40 System.err.write(b);
41 return b;
42 }
43
44 /***
45 * Close the stream
46 *
47 * @throws IOException if an exception is encountered when closing
48 */
49 public void close() throws IOException {
50 in.close();
51 }
52 }
This page was automatically generated by Maven