org.hwo.io.StreamReader(): Neue Eigenimplementation

thobaben_serialize
Harald Wolff 2014-08-24 13:05:50 +02:00
parent 2c9782fd45
commit a623c22f2e
1 changed files with 41 additions and 0 deletions

View File

@ -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);
}
}
}
}