3535 */
3636public class BoundedInputStream extends InputStream {
3737
38+ private static final int EOF = -1 ;
39+
3840 /** the wrapped input stream */
3941 private final InputStream in ;
4042
@@ -45,7 +47,7 @@ public class BoundedInputStream extends InputStream {
4547 private long pos = 0 ;
4648
4749 /** the marked position */
48- private long mark = - 1 ;
50+ private long mark = EOF ;
4951
5052 /** flag if close shoud be propagated */
5153 private boolean propagateClose = true ;
@@ -71,7 +73,7 @@ public BoundedInputStream(final InputStream in, final long size) {
7173 * @param in The wrapped input stream
7274 */
7375 public BoundedInputStream (final InputStream in ) {
74- this (in , - 1 );
76+ this (in , EOF );
7577 }
7678
7779 /**
@@ -84,7 +86,7 @@ public BoundedInputStream(final InputStream in) {
8486 @ Override
8587 public int read () throws IOException {
8688 if (max >= 0 && pos >= max ) {
87- return - 1 ;
89+ return EOF ;
8890 }
8991 final int result = in .read ();
9092 pos ++;
@@ -115,13 +117,13 @@ public int read(final byte[] b) throws IOException {
115117 @ Override
116118 public int read (final byte [] b , final int off , final int len ) throws IOException {
117119 if (max >=0 && pos >=max ) {
118- return - 1 ;
120+ return EOF ;
119121 }
120122 final long maxRead = max >=0 ? Math .min (len , max -pos ) : len ;
121123 final int bytesRead = in .read (b , off , (int )maxRead );
122124
123- if (bytesRead ==- 1 ) {
124- return - 1 ;
125+ if (bytesRead ==EOF ) {
126+ return EOF ;
125127 }
126128
127129 pos +=bytesRead ;
0 commit comments