我正在显示数据库中的数据,但是不起作用。 那就是给我的异常:FileNotFound但路径很好。 但是当我从浏览器中输入URL时,它可以正常工作
有我的代码:
@Override
protected String doInBackground(String... parametro)
{
try
{
URL url = new URL(urlMostrarClientes);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
InputStream inputStream = connection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuffer buffer = new StringBuffer();
String linha = "";
while ((linha = bufferedReader.readLine()) != null)
{
buffer.append(linha + "\n");
}
inputStream.close();
bufferedReader.close();
progressDialog.dismiss();
return buffer.toString().trim();
} catch (MalformedURLException e)
{
e.printStackTrace();
progressDialog.dismiss();
Log.v("vampiro","ERRO : " + e.toString());
} catch (ProtocolException e)
{
e.printStackTrace();
progressDialog.dismiss();
Log.v("vampiro","ERRO : " + e.toString());
} catch (IOException e) {
e.printStackTrace();
progressDialog.dismiss();
Log.v("vampiro","ERRO : " + e.toString());
}
return "ERRO";
}
答案 0 :(得分:0)
解决问题的三种方法: