I am very new to android development so forgive my ignorance. I need to be able to read some text from a remote webpage at say 15 minute intervals. The webpage itself contains just one word with no html tags or formatting. If this is possible if someone could point me in the right direction I'd appreciate it.
Thanks
Sure, try the following
try {
// Create a URL for the desired page
URL url = new URL("yoursite.com/thefile.txt");
// Read all the text returned by the server
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str = in.readLine();
in.close();
} catch (MalformedURLException e) {
} catch (IOException e) {
}
您可能希望将“in.close()”放在finally {}子句中,以确保它始终关闭
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.