// java code that connect to and read a web page
package javaapplication1;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;
public class JavaApplication1 {
public static void main(String[] args) {
try
{
URL website = new URL("http://www.collectivesolver.com/");
URLConnection urlcon = website.openConnection();
try (Scanner s = new Scanner(new InputStreamReader(urlcon.getInputStream()))) {
int count = 0;
while (s.hasNext()) {
System.out.println(s.next());
count++;
}
System.out.println("\ntokens: " + count);
}
}
catch(Exception e) {
System.out.println(e);
}
}
}
/*
run:
<!DOCTYPE
html>
<html>
<head>
<meta
charset="utf-8">
<title>Programming
&
Software
Q&A
|
CollectiveSolver</title>
<meta
name="description"
content="Programming
Questions
&
Answers
in
Java,
C#,
C,
C++,
PHP,
MySQL,
Python,
JavaScript,
WinAPI,
Win32,
VB.NET,
SQL,
HTML5,
CSS3,
DataBase,
WordPress,
Dot.NET,
jQuery,
openGL,
DOM,
HTML,
CSS,
phpMyAdmin,
XAMPP,
Windows">
...
tokens: 5526
*/