[英]Error java.io.FileNotFound BufferReader with InputStreamReader Java Android
I want the get some data from my database on my android application. 我想从我的Android应用程序上的数据库中获取一些数据。 This is my code:
这是我的代码:
try{
String nome = (String)arg0[0];
String stato = (String)arg0[1];
String link="http://www.example.org/AndroidPage.php";
String data = URLEncoder.encode("nome", "UTF-8") + "=" + URLEncoder.encode(nome, "UTF-8");
data += "&" + URLEncoder.encode("stato", "UTF-8") + "=" + URLEncoder.encode(stato, "UTF-8");
URL url = new URL(link);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();
String line = null;
// Read Server Response
while((line = reader.readLine()) != null)
{
sb.append(line);
break;
}
return sb.toString();
}catch(Exception e){
return new String("exception: " + e.toString());
}
If I comment the BufferReader statement I don't get any error. 如果我评论BufferReader语句,我不会收到任何错误。 Here is the error.. (The file exist in the server) http://i.stack.imgur.com/mb3sc.png
这是错误。.(文件存在于服务器中) http://i.stack.imgur.com/mb3sc.png
UPDATE: I resolved the problem.. The error was inside the php script, I forgot to write a semicolon. 更新:我解决了问题。错误是在php脚本内,我忘了写分号。
您是否已将Internet权限添加到清单?
<uses-permission android:name="android.permission.INTERNET" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.