libgdx/libgdx · error · RuntimeException
readline NYI
Error message
readline NYI
What it means
DataInputStream.readLine() in the GWT java.io emulator is explicitly not implemented and always throws RuntimeException("readline NYI"). The emulator only implements the binary read methods (readInt, readShort, readUTF, etc.); text-line reading was never ported because GWT has no blocking console/file stream model.
Source
Thrown at backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/java/io/DataInputStream.java:85
int count = is.read(b, off, len);
if (count <= 0) {
throw new EOFException();
}
off += count;
len -= count;
}
}
public int readInt () throws IOException {
int a = is.read();
int b = is.read();
int c = is.read();
int d = readUnsignedByte();
return (a << 24) | (b << 16) | (c << 8) | d;
}
public String readLine () throws IOException {
throw new RuntimeException("readline NYI");
}
public long readLong () throws IOException {
long a = readInt();
long b = readInt();
return (a << 32) | (b & 0xffffffffL);
}
public short readShort () throws IOException {
int a = is.read();
int b = readUnsignedByte();
return (short)((a << 8) | b);
}
public String readUTF () throws IOException {
int bytes = readUnsignedShort();
StringBuilder sb = new StringBuilder();
View on GitHub (pinned to 97f4086187)
Solutions
- Replace readLine() usage with BufferedReader.readLine() over an InputStreamReader on the asset stream, which the emulator supports.
- Reimplement line parsing manually: read bytes until '\n' via read() and build the String.
- Isolate the binary+text parser in a non-GWT source set and provide a GWT-specific reader.
- If a third-party library hits this, check for a GWT-compatible version or exclude that code path on html5.
Example fix
// before DataInputStream in = new DataInputStream(file.read()); String line = in.readLine(); // after BufferedReader reader = new BufferedReader(new InputStreamReader(file.read())); String line = reader.readLine();
Defensive patterns
Strategy: fallback
Prevention
- Never call DataInputStream.readLine() in GWT-compiled code; it always throws.
- Use BufferedReader.readLine over InputStreamReader for text.
- Audit shared parsers for readLine-on-DataInputStream before adding them to the GWT module.
When it happens
Trigger: Calling readLine() on a DataInputStream (or code that does, e.g. OBJ/CSV loaders, hand-rolled readers) anywhere in a GWT/html5 libGDX build. Also hit transitively when a library shared with desktop uses DataInputStream.readLine().
Common situations: Reusing a desktop file parser that mixes binary reads and readLine() and running it with GWTFile/asset streams on the html5 backend. Fails immediately at the first line read, both in SuperDevMode and compiled output.
Related errors
AI-assisted analysis of libgdx/libgdx@97f4086187 (2026-08-14).
Data as JSON: /api/errors/7c0cf01e2e9a6d5f.
Report an issue: GitHub.