代码转换,将java代码转换成C#代码,高手帮忙
Java code:
URL url = new URL("http://www.baidu.com");
URLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty( " User-agent " , " IE/7.0 " );
connection.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(),"Shift_JIS"));//根据对应编码接收
String line = null ;
StringBuilder sb = new StringBuilder();
while ((line = in.readLine()) != null ) {
sb.append(line);
}
in.close();
String trans=sb.toString();
System.out.print(trans);
C# code:
System.Net.WebClient client = new System.Net.WebClient();
client.Headers.Add("user-agent", " IE/7.0 ");
Stream data = client.OpenRead("http://www.baidu.com");
StreamReader reader = new StreamReader(data,Encoding.Default);
string s = reader.ReadToEnd();
data.Close();
reader.Close();
//Response.Write(s);
相关问答:
<html><head><title>[@title]</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<script language='javascript'>
function diyCheck ......
在asp里怎么调用java写的webservice方法,有很多方法
- <message name="RtPnrIn">
<part name="bstrPnrNO" type="s:string" />
<part name ......
怎么在控制台中输入类似下面的信息:
s1234 50
s1235 80
s1234 90
s1234 40
s1236 90
每当回车时 ......
我是个新手,做一个JSP网页,我要读出数据库正常,但是我要修改的时候,也就是读入的时候出现乱码,请高手告诉我怎么解决,先谢谢了。
request.setCharacterEncoding("UTF-8");
把编码统一
/**
......
要求是输入一个数字,然后按照下面的方式输出(顺时针旋转)
比如 输入 2
则输出为
1 2 3
8 9 4
7 6 5
输入 6
则输出为
1 2 3 4 5 6
20 21 22 23 24 7
19 32 33 34 25 8
18 31 36 ......