diff --git a/src/org/hwo/io/StreamReader.java b/src/org/hwo/io/StreamReader.java new file mode 100644 index 0000000..e0f3395 --- /dev/null +++ b/src/org/hwo/io/StreamReader.java @@ -0,0 +1,41 @@ +package org.hwo.io; + +import java.io.IOException; +import java.io.InputStream; + +public class StreamReader { + + private InputStream stream; + + public StreamReader(InputStream stream) + { + this.stream = stream; + } + + public int read(byte[] buffer,int offset,int len) throws IOException + { + return this.stream.read(buffer, offset, len); + } + + public String readLine() throws IOException + { + StringBuilder builder = new StringBuilder(); + while (true) + { + int ch = this.stream.read(); + + if ((ch == -1)||(ch == '\n')) + return builder.toString(); + + if (ch >= 32) + { + builder.append((char)ch); + } + } + } + + + + + +}