You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2002/09/09 07:43:39 UTC
cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient AutoCloseInputStream.java
dion 2002/09/08 22:43:39
Modified: httpclient/src/java/org/apache/commons/httpclient
AutoCloseInputStream.java
Log:
Documentation mainly
Revision Changes Path
1.2 +48 -10 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/AutoCloseInputStream.java
Index: AutoCloseInputStream.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/AutoCloseInputStream.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AutoCloseInputStream.java 2 Sep 2002 14:52:47 -0000 1.1
+++ AutoCloseInputStream.java 9 Sep 2002 05:43:39 -0000 1.2
@@ -62,7 +62,9 @@
package org.apache.commons.httpclient;
-import java.io.*;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
/**
* Closes a HttpConnection as soon as the end of the stream is reached.
@@ -72,28 +74,64 @@
*/
class AutoCloseInputStream extends FilterInputStream {
+ /** the connection the input stream comes from */
private HttpConnection conn;
+ /**
+ * Create a new auto closing stream for the provided connection
+ *
+ * @param in the input stream to read from
+ * @param conn the connection to close when done reading
+ */
public AutoCloseInputStream(InputStream in, HttpConnection conn) {
super(in);
this.conn = conn;
}
- public int read() throws java.io.IOException {
+ /**
+ * Reads the next byte of data from the input stream.
+ *
+ * @throws IOException when there is an error reading
+ * @return the character read, or -1 for EOF
+ */
+ public int read() throws IOException {
int l = super.read();
- if (l == -1) conn.close();
+ if (l == -1) {
+ conn.close();
+ }
return l;
}
- public int read(byte[] b, int off, int len) throws java.io.IOException {
+ /**
+ * Reads up to <code>len</code> bytes of data from the stream.
+ *
+ * @param b a <code>byte</code> array to read data into
+ * @param off an offset within the array to store data
+ * @param len the maximum number of bytes to read
+ * @return the number of bytes read or -1 for EOF
+ * @throws IOException if there are errors reading
+ */
+ public int read(byte[] b, int off, int len) throws IOException {
int l = super.read(b, off, len);
- if (l == -1) conn.close();
+ if (l == -1) {
+ conn.close();
+ }
return l;
}
- public int read(byte[] b) throws java.io.IOException {
+ /**
+ * Reads some number of bytes from the input stream and stores them into the
+ * buffer array b.
+ *
+ * @param b a <code>byte</code> array to read data into
+ * @return the number of bytes read or -1 for EOF
+ * @throws IOException if there are errors reading
+ */
+ public int read(byte[] b) throws IOException {
int l = super.read(b);
- if (l == -1) conn.close();
+ if (l == -1) {
+ conn.close();
+ }
return l;
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>