Locale-Sensitive Java Method
java.io.DataInputStream
public DataInputStream(InputStream in)
Internationalization (I18n) Method Overview
The DataInputStream class includes a method readLine() , which
reads the next line of text from the underlying InputStream .
It reads successive bytes, converting each byte separately into a character,
until it encounters a line terminator or end of file. The
characters read in are then returned as a Java String object.
I18n Issues
Because this class - via the readLine() method - attempts to convert
each individual byte from the input stream into a two-byte UTF-16 character,
it does not support input of the full Unicode character set.
Each byte that is read is converted to a two-byte
char type by zero-extension. Every character in this string will have a value less
than \u0100, that is, (char)256.
Suggested Replacement
java.io.InputStreamReader
public InputStreamReader
(InputStream in,
String charsetName)
throws UnsupportedEncodingException
Combined with:
java.io.BufferedReader
public String readLine()
throws IOException
Instead of:
DataInputStream d = new DataInputStream(in);
String aLine = d.readLine();
Use:
BufferedReader reader = new BufferedReader(
new InputStreamReader
(in, charset));
String aLine = reader.readLine();
Locale-Sensitive Java Methods
|