[問題] 請問一個關於抓取網頁的問題
public static void main(String args[]) throws Exception{
String param;
param = "id="+URLEncoder.encode("王小明","UTF-8");
URL url = new URL("http://j.snpy.org/net/get.php?"+param);
URLConnection conn = url.openConnection();
InputStreamReader in = new InputStreamReader(conn.getInputStream(),"UTF-8");
int data = in.read();
FileWriter out = new FileWriter("page.htm");
System.out.println(param);
System.out.println("=======================================");
while(data!=-1){
System.out.print((char)data);
out.write((char)data);
out.flush();
data=in.read();
}
out.close();
以上是我的程式碼,我先送一個GET過去,回傳回來的網頁,會有"王小明"中文字出現
我在Console的部分,可以正常的顯示出來中文字,但是在我的page.htm裡面,卻無法
存成正常的中文字,而形成亂碼,想請問是那邊有了問題?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.84.27.29
→
02/22 12:46, , 1F
02/22 12:46, 1F
→
02/22 14:18, , 2F
02/22 14:18, 2F
→
02/22 22:02, , 3F
02/22 22:02, 3F
→
02/22 23:03, , 4F
02/22 23:03, 4F
→
02/22 23:05, , 5F
02/22 23:05, 5F