forked from LupusNobilis/java-org.hwo
42 lines
633 B
Java
42 lines
633 B
Java
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|