在android HttpURLConnection中打开输入流时出现java.io.FileNotFoundException

时间:2015-12-18 13:34:32

标签: android inputstream httpurlconnection

我正在申请所有请求正在工作,除了一个请求给我以下错误

java.io.FileNotFoundException: baseURL/MyListings/editListing
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:197)
at com.forsale.forsale.controller.manager.ForSaleNetworkManager.execute(ForSaleNetworkManager.java:137)
at com.forsale.forsale.controller.manager.ForSaleServerManager$37.doInBackground(ForSaleServerManager.java:2820)
at com.forsale.forsale.controller.manager.ForSaleServerManager$37.doInBackground(ForSaleServerManager.java:2795)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)

我真的不知道这是什么问题。

修改

请求正在邮递员

1 个答案:

答案 0 :(得分:1)

由于拼写错误的方法名称而发生文件未找到异常。

请分享邮差和邮件的链接在代码中使用,更好理解。

检查成功的响应代码200

if (urlConnection.getResponseCode() == 200) {
    InputStream in = new BufferedInputStream(urlConnection.getInputStream());
    json = readStream(in);
}else {
    json = "{\"result\":\"fail\"}";
}