Browse Source

minor cleanups

tags/2.0.1
Jonathan Cobb 5 years ago
parent
commit
5091e557f6
2 changed files with 5 additions and 7 deletions
  1. +4
    -6
      src/main/java/org/cobbzilla/util/io/multi/MultiStream.java
  2. +1
    -1
      src/main/java/org/cobbzilla/util/io/regex/RegexFilterReader.java

+ 4
- 6
src/main/java/org/cobbzilla/util/io/multi/MultiStream.java View File

@@ -26,8 +26,6 @@ public class MultiStream extends InputStream {


public MultiStream (InputStream r) { this(r, false); } public MultiStream (InputStream r) { this(r, false); }


protected int getEndOfStreamMarker() { return 0; }

public void addStream (InputStream in) { public void addStream (InputStream in) {
if (endOfStreams) { if (endOfStreams) {
log.warn("addStream: endOfStreams is true, not adding InputStream"); log.warn("addStream: endOfStreams is true, not adding InputStream");
@@ -42,10 +40,10 @@ public class MultiStream extends InputStream {
} }


@Override public int read() throws IOException { @Override public int read() throws IOException {
int val = currentStream.read();
final int val = currentStream.read();
if (val == -1) { if (val == -1) {
if (streamIndex == streams.size()-1) { if (streamIndex == streams.size()-1) {
return endOfStreams ? -1 : getEndOfStreamMarker();
return endOfStreams ? -1 : 0;
} }
currentStream.close(); currentStream.close();
streamIndex++; streamIndex++;
@@ -56,10 +54,10 @@ public class MultiStream extends InputStream {
} }


@Override public int read(byte[] buf, int off, int len) throws IOException { @Override public int read(byte[] buf, int off, int len) throws IOException {
int count = currentStream.read(buf, off, len);
final int count = currentStream.read(buf, off, len);
if (count == -1) { if (count == -1) {
if (streamIndex == streams.size()-1) { if (streamIndex == streams.size()-1) {
return endOfStreams ? -1 : getEndOfStreamMarker();
return endOfStreams ? -1 : 0;
} }
currentStream.close(); currentStream.close();
streamIndex++; streamIndex++;


+ 1
- 1
src/main/java/org/cobbzilla/util/io/regex/RegexFilterReader.java View File

@@ -76,7 +76,7 @@ public class RegexFilterReader extends BufferedReader {
boolean eof = false; boolean eof = false;
// fill the buffer with the underlying stream // fill the buffer with the underlying stream
while (len != buffer.length) { while (len != buffer.length) {
int val = super.read(buffer, len, buffer.length - len);
final int val = super.read(buffer, len, buffer.length - len);
if (val == -1) { if (val == -1) {
eof = true; eof = true;
break; break;


Loading…
Cancel
Save