Name: paC48320 Date: 10/08/97
1. Creates a properties file. For example, GrammarReader.properties
Contents follows:
BadDoubleNumberFormatMessage=ä
End of contents.
This properties contains one Russian letter with byte value equals to 228.
2. Crates a demo class to read this file
Source code follows:
// Copyright 1997 Ruxy Consulting :-|
import java.io.*;
import java.util.*;
public class test {
public static void main(String[] args){
ResourceBundle properties = ResourceBundle.getBundle("GrammarReader");
String s = properties.getString("BadDoubleNumberFormatMessage");
byte[] tmp = s.getBytes();
System.out.println(tmp[0]);
System.out.println( s );
}
}
End of source.
Compile and run this program. GrammarReader.properties must be in
same dir as test.class
3. Output:
63
?
End of output.
But output must be
228
ä
5.Problem appears in java.util.Properties class
that actually reads the properties file.
Part of source follows:
public synchronized void load(InputStream in) throws IOException {
in = Runtime.getRuntime().getLocalizedInputStream(in);
End of source.
But getLocalizedInputStream IS DEPRECATED
according to JDK1.1.4 online docs.
After that in code i found:
key.append((char)ch);
but I think it must be
key.append((byte)ch)
======================================================================
- duplicates
-
JDK-4077980 Properties.save() and Properties.load() are not non-ASCII safe
-
- Closed
-