0
私はこのコードを持っており、URLが"http://www.example.com/someFile.txt"であれば問題なく動作します。しかし、"http://www.example.com/export/something"(サーバー上のURL書き換え/ .htaccessの助けを借りて)デスクトップのブラウザで再び同じ結果がAndroidに出力されると、エラーエラーこの問題を解決するためのAndroidでURL書き換えhttpGet + InputStreamReader
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
String result = "";
HttpGet httpGet = new HttpGet("http://www.example.com/export/notWorking");
HttpResponse response = null;
try {
response = httpClient.execute(httpGet, localContext);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = null;
while ((line = reader.readLine()) != null){
result += line;
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ホット
の文字0での入力の終了:ファイル/ワット?
EDIT:
HttpParams params = new BasicHttpParams();
params.setParameter(CoreProtocolPNames.USER_AGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.71");
が解決しないユーザエージェントのヘルプ。