我正在使用以下代码从网络获取数据,但它总是能够提供帮助。任何人都可以帮助我
公共类NetworkManager {
public NetworkManager(){
}
public static String WebQuery(String urlstring)
{
String resultToDisplay = "";
InputStream in = null;
try {
URL url = new URL(urlstring);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
in = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
resultToDisplay = reader.readLine();
//bitmap = BitmapFactory.decodeStream(in);
}
catch(Exception e){
resultToDisplay = "";
System.out.println(e.getMessage());
}
return resultToDisplay;
}
}