Tuesday, January 28, 2014

HttpURLConnection in connection.getInputStream () reported abnormal FileNotFoundException


            
The AVD test no problem. Times change to the device FileNotFound abnormalities frequently reported this exception. Help us to see.
Code is as follows:
 
public class HttpAssist {


public static String doPost (JSONObject json) throws IOException {
URL postUrl = new URL (Config.url);
HttpURLConnection connection = (HttpURLConnection) postUrl.openConnection ();
connection.setDoOutput (true);
connection.setDoInput (true);
connection.setRequestMethod ("POST");
connection.setUseCaches (false);

connection.connect ();
OutputStreamWriter out = new OutputStreamWriter (connection
. GetOutputStream ());
out.write (Config.getParameterName + "=" + json.toString ());
out.flush ();
out.close (); / / flush and close
BufferedReader reader = new BufferedReader (new InputStreamReader (connection.getInputStream (), "utf-8"));
String line = "";
String res = "";
while ((line = reader.readLine ())! = null) {
res + = line;
System.out.println (line);
}
reader.close ();
connection.disconnect ();

return res;
}
}


Abnormal follows:


Is not always reported, but often reported this exception. Investigation for a long time have not found something useful. You, to see you. . .
Reply:
Server daemon is not reported an error, such as a 500 error or something.
Reply:
Get current proposal before the judge responseCode 200.
Reply:
reference to the second floor birdsaction reply: Get current proposal before
judgment responseCode is 200
good my first try.
Reply:
This is your ip should be, you need this test within the LAN phone with this pc is using the same router!
Reply:
references, 4th Floor u011133213 reply:
you this ip is, it should be, you need this test phone with this pc is using the same router LAN !

Well yes. Otherwise not visit.
Reply:
Then you'll see the return code to determine the next state
Reply:
The same question, I also encountered this problem. And network access permissions are configured.

No comments:

Post a Comment