In java, what code do I need to get from "http://www.mysite.com/text.txt" to a Scanner that parses the resulting text contained in the site in as few lines as possible.
Scanner sc = new Scanner(new URL("http://www.mysite.com/text.txt").openStream());
URL yahoo = new URL("http://www.yahoo.com/");
BufferedReader in = new BufferedReader(
new InputStreamReader(
yahoo.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With