Methods Summary |
---|
public void | close()Closes the underlying stream.
s.close();
|
public void | consume()Consumes all unread bytes of this stream. After a call to this method
this stream will have reached EOF.
while (read() != -1) {
}
|
public boolean | hasMoreParts()Determines if the underlying stream has more parts (this stream has
not seen an end boundary).
return moreParts;
|
private boolean | matchBoundary()
for (int i = 0; i < boundary.length; i++) {
int b = s.read();
if (b != boundary[i]) {
if (b != -1) {
s.unread(b);
}
for (int j = i - 1; j >= 0; j--) {
s.unread(boundary[j]);
}
return false;
}
}
/*
* We have a match. Is it an end boundary?
*/
int prev = s.read();
int curr = s.read();
moreParts = !(prev == '-" && curr == '-");
do {
if (curr == '\n" && prev == '\r") {
break;
}
prev = curr;
} while ((curr = s.read()) != -1);
if (curr == -1) {
moreParts = false;
parenteof = true;
}
eof = true;
return true;
|
public boolean | parentEOF()Determines if the parent stream has reached EOF
return parenteof;
|
public int | read()
if (eof) {
return -1;
}
if (first) {
first = false;
if (matchBoundary()) {
return -1;
}
}
int b1 = s.read();
int b2 = s.read();
if (b1 == '\r" && b2 == '\n") {
if (matchBoundary()) {
return -1;
}
}
if (b2 != -1) {
s.unread(b2);
}
parenteof = b1 == -1;
eof = parenteof;
return b1;
|