change Chinese annotation to English
This commit is contained in:
parent
54dde0624e
commit
d4dc2caad2
|
@ -53,22 +53,22 @@ public class GstoreConnector {
|
|||
String urlNameString = url + "/" + param;
|
||||
System.out.println("request: "+urlNameString);
|
||||
URL realUrl = new URL(urlNameString);
|
||||
// 打开和URL之间的连接
|
||||
// open the connection with the URL
|
||||
URLConnection connection = realUrl.openConnection();
|
||||
// 设置通用的请求属性
|
||||
// set request properties
|
||||
connection.setRequestProperty("accept", "*/*");
|
||||
connection.setRequestProperty("connection", "Keep-Alive");
|
||||
//set agent to avoid: speed limited by server if server think the client not a browser
|
||||
connection.setRequestProperty("user-agent",
|
||||
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||
// 建立实际的连接
|
||||
// create the real connection
|
||||
connection.connect();
|
||||
|
||||
long t0 = System.currentTimeMillis(); //ms
|
||||
|
||||
// 获取所有响应头字段
|
||||
// get all response header fields
|
||||
Map<String, List<String>> map = connection.getHeaderFields();
|
||||
// 遍历所有的响应头字段
|
||||
// traverse all response header fields
|
||||
//for (String key : map.keySet()) {
|
||||
// System.out.println(key + "--->" + map.get(key));
|
||||
//}
|
||||
|
@ -77,7 +77,7 @@ public class GstoreConnector {
|
|||
//System.out.println("Time to get header: "+(t1 - t0)+" ms");
|
||||
//System.out.println("============================================");
|
||||
|
||||
// 定义 BufferedReader输入流来读取URL的响应
|
||||
// define BufferedReader to read the response of the URL
|
||||
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
|
@ -94,7 +94,7 @@ public class GstoreConnector {
|
|||
System.out.println("error in get request: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 使用finally块来关闭输入流
|
||||
// use finally to close the input stream
|
||||
finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
|
@ -132,21 +132,21 @@ public class GstoreConnector {
|
|||
String urlNameString = url + "/" + param;
|
||||
System.out.println("request: "+urlNameString);
|
||||
URL realUrl = new URL(urlNameString);
|
||||
// 打开和URL之间的连接
|
||||
// open the connection with the URL
|
||||
URLConnection connection = realUrl.openConnection();
|
||||
// 设置通用的请求属性
|
||||
// set request properties
|
||||
connection.setRequestProperty("accept", "*/*");
|
||||
connection.setRequestProperty("connection", "Keep-Alive");
|
||||
//set agent to avoid: speed limited by server if server think the client not a browser
|
||||
connection.setRequestProperty("user-agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||
// 建立实际的连接
|
||||
// create the real connection
|
||||
connection.connect();
|
||||
|
||||
long t0 = System.currentTimeMillis(); //ms
|
||||
|
||||
// 获取所有响应头字段
|
||||
// get all response header fields
|
||||
Map<String, List<String>> map = connection.getHeaderFields();
|
||||
// 遍历所有的响应头字段
|
||||
// traverse all response header fields
|
||||
//for (String key : map.keySet()) {
|
||||
// System.out.println(key + "--->" + map.get(key));
|
||||
//}
|
||||
|
@ -154,7 +154,7 @@ public class GstoreConnector {
|
|||
long t1 = System.currentTimeMillis(); // ms
|
||||
//System.out.println("Time to get header: "+(t1 - t0)+" ms");
|
||||
|
||||
// 定义 BufferedReader输入流来读取URL的响应
|
||||
// define BufferedReader to read the response of the URL
|
||||
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
|
||||
char chars[] = new char[2048];
|
||||
int b;
|
||||
|
@ -170,7 +170,7 @@ public class GstoreConnector {
|
|||
//System.out.println("error in get request: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 使用finally块来关闭输入流
|
||||
// use finally to close the input stream
|
||||
finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
|
@ -485,9 +485,9 @@ public class GstoreConnector {
|
|||
//To count the time cost
|
||||
//long startTime=System.nanoTime(); //ns
|
||||
//long startTime=System.currentTimeMillis(); //ms
|
||||
//doSomeThing(); //测试的代码段
|
||||
//long endTime=System.currentTimeMillis(); //获取结束时间
|
||||
//System.out.println("程序运行时间: "+(end-start)+"ms");
|
||||
//doSomeThing(); //test code
|
||||
//long endTime=System.currentTimeMillis(); //get end time
|
||||
//System.out.println("run time: "+(end-start)+"ms");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue