請告訴我寄與GET方法PARAMS在HttpURLConnection的.. 我使用這個代碼的方式..但我不知道我應該用什麼方法來發送PARAMS如何使用GET方法發送PARAMS在HttpURLConnection的Android中
上is = connection.getInputStream();
這裏
它投擲例外FileNotFoundException
是代碼..
//is this line is correct?
url = new URL(u + "?" + getQuery(params));
Log.v("testing", url.toString());
connection = (HttpURLConnection) url.openConnection();
connection.setReadTimeout(10000);
connection.setConnectTimeout(15000);
connection.setRequestMethod("GET");
connection.setDoInput(true);
connection.setDoOutput(true);
os = connection.getOutputStream();
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
//bw.write(getQuery(params));
bw.flush();
bw.close();
os.close();
connection.connect();
is = connection.getInputStream();
String line = "";
BufferedReader br = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
while ((line = br.readLine()) != null){
sb.append(line);
}
'u +「?」 + getQuery(params)'。足夠了。這就是你必須要做的。刪除作家的東西。並沒有輸出承諾。不要混淆輸出流。 – greenapps