Hi developers,
I want to send the the "id", "name", "score" to my server ( write the
records to server in a file named "ranking", path is http://
***.***.***.***/man/ranking,
I am sure the file exist, i have created it before, then i use the following
code to write, but it can't write into successful, Can anyone tell me why?
code:
private boolean updateRecord(String uid, String name, int score) {
HttpURLConnection conn = null;
try {
URL url = new URL("http://***.***.***.***/man/ranking");
conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
DataOutputStream dos = new
DataOutputStream(conn.getOutputStream());
dos.writeUTF("UPDATE");
dos.writeUTF(uid);
dos.writeUTF(name);
dos.writeUTF(String.valueOf(score));
dos.flush();
dos.close();
DataInputStream dis = new
DataInputStream(conn.getInputStream());
String resultInfo = dis.readUTF();
if (resultInfo != null && !"ERROR".equals(resultInfo)) {
return true;
}
dis.close();
} catch (Exception e) {
Log.e("", "", e);
} finally {
if (conn != null)
conn.disconnect();
}
return false;
}
------------------------------------------------------------------------------------------------------
Error log following
09-23 12:01:42.041: INFO/AndroidRuntime(453): NOTE: attach of thread 'Binder
Thread #3' failed
09-23 12:01:42.561: ERROR/(431): java.io.FileNotFoundException: http://
***.***.***.***/man/ranking
09-23 12:01:42.561: ERROR/(431): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:521)
09-23 12:01:42.561: ERROR/(431): at
a.test.conn.AtestActivity.updateRecord(AtestActivity.java:36)
09-23 12:01:42.561: ERROR/(431): at
a.test.conn.AtestActivity.onCreate(AtestActivity.java:18)
09-23 12:01:42.561: ERROR/(431): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-23 12:01:42.561: ERROR/(431): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
09-23 12:01:42.561: ERROR/(431): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-23 12:01:42.561: ERROR/(431): at
android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-23 12:01:42.561: ERROR/(431): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-23 12:01:42.561: ERROR/(431): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-23 12:01:42.561: ERROR/(431): at
android.os.Looper.loop(Looper.java:123)
09-23 12:01:42.561: ERROR/(431): at
android.app.ActivityThread.main(ActivityThread.java:3683)
09-23 12:01:42.561: ERROR/(431): at
java.lang.reflect.Method.invokeNative(Native Method)
09-23 12:01:42.561: ERROR/(431): at
java.lang.reflect.Method.invoke(Method.java:507)
09-23 12:01:42.561: ERROR/(431): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-23 12:01:42.561: ERROR/(431): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-23 12:01:42.561: ERROR/(431): at
dalvik.system.NativeStart.main(Native Method)
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en