获得null作为回报。请修复
public class HttpURLConnectionHandler {
protected String urlG = "http://mywebsite.000webhostapp.com/";
public String sendText() {
try {
URL url = new URL(urlG + "TopicContents/tryfile.txt");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
InputStream is = conn.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
String response = "";
while ((line = rd.readLine()) != null) {
response = (response + line + "\n");
}
rd.close();
return response;
} catch (Exception e) {
return "error: "+e.getMessage();
}
}
}
returnig“error:null”我从2天开始尝试每一个方法从服务器获取文本文本中的文本。请帮忙;(
我可以使用echo n stuff将文件从.txt更改为php但是请帮我从服务器获取字符串