Name: dsC58869 Date: 02/10/2000
The method
java.net.URL.openConnection() hangs up the Java VM
when character encoding is not ASCII (e.g. Cp037).
Here is a minimized test:
public class URLTest05 {
public static void main(String[] args) {
try {
String str = "http://www.sparc.spb.su/index.html";
System.out.println(str);
InputStreamReader isr = new InputStreamReader(System.in);
System.out.println(isr.getEncoding());
System.out.flush();
URL url = new URL(str);
URLConnection conn = url.openConnection();
conn.getInputStream();
System.out.println("OKAY");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Output:
%echo $LANG
C
%java URLTest05
http://www.sparc.spb.su/index.html
ISO8859_1
OKAY
%java -Dfile.encoding=Cp037 URLTest05
êúúùzaaªªªKóùüÖâKóùéKóñaëòäàºKêúöô§Èù^T^?M-^U§
^C
It means (converted from Cp037 to ASCII):
http://www.sparc.spb.su/index.html
Cp037
======================================================================
- duplicates
-
JDK-4415172 sun.net.www.http.HttpClient.class fails on a non-ascii platform
-
- Closed
-
- relates to
-
JDK-4378278 java.io.PrintStream(..., String encoding) constructor
-
- Resolved
-