Hi ladies and gentlemen. I have a question that I hope you would do me a favour. Thanks!
I wrote a Java program which will get the content (or source code) of HTML pages. The content often contains Chinese. When I use Java 1.2.2 to compile and run the program, the Chinese can be displayed correctly. But If I compile and run by Java SDK 1.4.1, the Chinese will become question marks. Do you have any solution or advice to this problem? The source code of the program is shown below for reference:
-------------------------------------
import java.io.*;
import java.net.*;
public class TEST
{
public static void main (String args[]) throws Exception
{
URL url = new URL(" HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
InputStream in = conn.getInputStream();
String line, s;
while (in.available() > 0)
{
byte[] b = new byte[1000];
in.read(b);
s = new String(b);
System.out.println(s);
}
in.close();
}
}
I wrote a Java program which will get the content (or source code) of HTML pages. The content often contains Chinese. When I use Java 1.2.2 to compile and run the program, the Chinese can be displayed correctly. But If I compile and run by Java SDK 1.4.1, the Chinese will become question marks. Do you have any solution or advice to this problem? The source code of the program is shown below for reference:
-------------------------------------
import java.io.*;
import java.net.*;
public class TEST
{
public static void main (String args[]) throws Exception
{
URL url = new URL(" HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
InputStream in = conn.getInputStream();
String line, s;
while (in.available() > 0)
{
byte[] b = new byte[1000];
in.read(b);
s = new String(b);
System.out.println(s);
}
in.close();
}
}