问一个简单的问题!!! 我写了一个下载网页的程序,我运行的时候下载的中文是乱码,是不是因为big-endian和little-endian的问题,我要调整为网页原来的样子应该怎么做,难道要把每个汉字字符都手动调整吗??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.net.*;import java.io.*;public class SourceViewer2 { public static void main (String[] args) { if (args.length > 0) { try { URL u = new URL(args[0]); URLConnection uc = u.openConnection(); InputStream raw = uc.getInputStream(); InputStream buffer = new BufferedInputStream(raw); Reader r = new InputStreamReader(buffer); int c; while ((c = r.read()) != -1) { System.out.print((char) c); } } catch (MalformedURLException ex) { System.err.println(args[0] + " is not a parseable URL"); } catch (IOException ex) { System.err.println(ex); } } }} C:\Documents and Settings\Fantasy\Desktop\temp>javac Test.javaC:\Documents and Settings\Fantasy\Desktop\temp>java Test http://localhost:8090/index.jsp<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>::我顶你个肺-银行管理系统::</title><link href="CSS/mycss.css" rel="stylesheet" type="text/css"></head><body><table width="377" height="34" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th class="bigtitle">我顶你个肺-24小时自助银行</th> </tr></table><br><form name="form1" method="post" action=""><table width="469" height="84" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th width="178" align="right">帐号:</th> <td width="291"> <input type="text" name="textfield"> </td> </tr> <tr> <th align="right">密码:</th> <td><input type="text" name="textfield2"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="确定"> <input type="reset" value="重置"></td> </tr></table></form></body></html>C:\Documents and Settings\Fantasy\Desktop\temp>------------------------------------为什么我没发现乱码------------ 楼主可以在程序中的适当位置加上这样的代码:(URLConnection)uc.setRequestProporty("Accept-Language","X"),其中X是你想要以何种语言接收文件(各种语言字符的代号,在IE的工具中可以找到),比如说,如果你想将一个阿拉伯文的google站点的首页下载下来,而你又没写上这句(默认的是中文),那收到的就是乱码了。 我是一个JAVA菜鸟,请教一些关于控制权限的问题 java class文件防止反编译最强免费软件推荐 一个关数组元素匹配的问题 提供较全的Oreilly书籍下载,顺便进行本月第二次散分(来者有分) 请问开发一个连锁超市进销存管理系统,用SWING还是WEB方式编程好?急!!! 为什么不能加载声音和图像 我是一个新手,想问一下关于构造函数的问题?(在线等待。。) Linux下到底如何设置JDK的环境变量 哪里可以下载到WEBLOGIC 谢谢各位!!! 请问闪烁短信是如何实现的,能否说一下,或提供资源! 为什么总出现指针异常? 节点的增删改查问题
import java.io.*;public class SourceViewer2 { public static void main (String[] args) { if (args.length > 0) {
try {
URL u = new URL(args[0]);
URLConnection uc = u.openConnection();
InputStream raw = uc.getInputStream();
InputStream buffer = new BufferedInputStream(raw);
Reader r = new InputStreamReader(buffer);
int c;
while ((c = r.read()) != -1) {
System.out.print((char) c);
}
}
catch (MalformedURLException ex) {
System.err.println(args[0] + " is not a parseable URL");
}
catch (IOException ex) {
System.err.println(ex);
} }
}}
ndex.jsp<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>::我顶你个肺-银行管理系统::</title>
<link href="CSS/mycss.css" rel="stylesheet" type="text/css">
</head><body>
<table width="377" height="34" border="0" align="center" cellpadding="0" cellspa
cing="0">
<tr>
<th class="bigtitle">我顶你个肺-24小时自助银行</th>
</tr>
</table>
<br>
<form name="form1" method="post" action="">
<table width="469" height="84" border="0" align="center" cellpadding="0" cellspa
cing="0">
<tr>
<th width="178" align="right">帐号:</th>
<td width="291">
<input type="text" name="textfield"> </td>
</tr>
<tr>
<th align="right">密码:</th>
<td><input type="text" name="textfield2"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="确定">
<input type="reset" value="重置"></td>
</tr>
</table>
</form>
</body>
</html>C:\Documents and Settings\Fantasy\Desktop\temp>------------------------------------为什么我没发现乱码------------
(URLConnection)uc.setRequestProporty("Accept-Language","X"),其中X是你想要以何种语言接收文件(各种语言字符的代号,在IE的工具中可以找到),比如说,如果你想将一个阿拉伯文的google站点的首页下载下来,而你又没写上这句(默认的是中文),那收到的就是乱码了。