01: package pygmy.nntp;
02:
03: import pygmy.core.InternetInputStream;
04: import pygmy.core.Http;
05:
06: import java.io.IOException;
07: import java.io.InputStream;
08:
09: public class NntpInputStream extends InternetInputStream {
10:
11: public NntpInputStream(InputStream in) {
12: super (in);
13: }
14:
15: public String readText() throws IOException {
16: StringBuffer buffer = new StringBuffer();
17: while (true) {
18: StringBuffer line = readBuffer();
19: if (line == null
20: || (line.length() == 1 && line.charAt(0) == '.')) {
21: break;
22: } else if (line.length() > 1 && line.charAt(0) == '.'
23: && line.charAt(1) == '.') {
24: line.deleteCharAt(0);
25: buffer.append(line);
26: } else {
27: buffer.append(line);
28: }
29: buffer.append(Http.CRLF);
30: }
31: return buffer.toString();
32: }
33: }
|