已经在另一篇文章中询问过,但没有解决方案,请参阅下面的脚本,我该如何更改,请完整演示,以便我可以在网络中断时设置 readtimeout
根本我必须连接到一个url,只读一行,把它作为一个字符串......完成希望你能举个例子。欢迎任何其他工作方式.. thx
try {
URL url = new URL("http://mydomain/myfile.php");
//url.setReadTimeout(5000); does not work
InputStreamReader testi= new InputStreamReader(url.openStream());
BufferedReader in = new BufferedReader(testi);
//in.setReadTimeout(5000); does not work
stri = in.readLine();
Log.v ("GotThat: ",stri);
in.close();
} catch (MalformedURLException e) {
} catch (IOException e) {
}