httpUrlConnectionでGETメソッドを使用してパラメータを送信する方法を教えてください。 このコードを使用していますが、どのメソッドを使用してパラメータを送信する必要があるかわかりません。AndroidのHttpUrlConnectionでGETメソッドを使用してparamsを送信する方法
ここで
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