forked from LupusNobilis/java-org.hwo
org.hwo.io.StreamReader(): Neue Eigenimplementation
parent
2c9782fd45
commit
a623c22f2e
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue