mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fixes InputStreamReader one-by-one read
This commit is contained in:
parent
8cbb6477cb
commit
744033b118
|
@ -64,7 +64,7 @@ public class TInputStreamReader extends TReader {
|
|||
|
||||
@Override
|
||||
public int read() throws TIOException {
|
||||
if (eof) {
|
||||
if (eof && outBuffer.end()) {
|
||||
return -1;
|
||||
}
|
||||
if (!outBuffer.end()) {
|
||||
|
|
|
@ -43,6 +43,21 @@ public class InputStreamReaderTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readsCharsOneByOne() throws IOException {
|
||||
String str = "foo bar baz";
|
||||
byte[] bytes = new byte[str.length()];
|
||||
for (int i = 0; i < str.length(); ++i) {
|
||||
bytes[i] = (byte)str.charAt(i);
|
||||
}
|
||||
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
|
||||
InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
|
||||
assertEquals('f', reader.read());
|
||||
assertEquals('o', reader.read());
|
||||
assertEquals('o', reader.read());
|
||||
assertEquals(' ', reader.read());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readsManyChars() throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
Loading…
Reference in New Issue
Block a user