【发布时间】:2011-04-25 20:00:42
【问题描述】:
我需要从服务器(wamp test.json 上的本地)加载我的 android 应用程序中的文件,但我收到错误 PERMISSION DENIED 。我犯了什么错误?我需要额外配置 wamp 吗? (我可以访问 - 从浏览器和另一个空白的 android 应用程序下载该文件,在主要活动中使用相同的代码)
try {
URL url = new URL("http://10.0.2.2/test/test.json");
URLConnection urlconnection = url.openConnection();
long l = urlconnection.getContentLength();
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
StringBuffer buffer=new StringBuffer();
while ((line = in.readLine()) != null)
{
buffer.append(line);
}
in.close();
Object obj = JSONValue.parse(buffer.toString());
JSONArray array = (JSONArray) obj;
elements.load(buffer.toString());
} catch (Exception exc) {
exc.printStackTrace();
}
【问题讨论】:
-
您是否缺少
internet权限? -
谢谢!!!我很笨,我忘了补充!