final String URL = "http://www.java-forum.org/641003-post3.html";
Scanner sc = new Scanner(new URL(URL).openStream(), "ISO-8859-1");
while (sc.hasNextLine()) {
String s = sc.nextLine();
if (s.contains("Beiträge")) {
System.out.println(s.trim());
break;
}
}
import java.util.Scanner;
import java.net.URL;
public class Test_Class {
public static void main(String[] args) {
final String URL = "http://www.java-forum.org/641003-post3.html";
Scanner sc = new Scanner(new URL(URL).openStream(), "ISO-8859-1");
while (sc.hasNextLine()) {
String s = sc.nextLine();
if (s.contains("Beiträge")) {
System.out.println(s.trim());
break;
}
}
}
}
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Unhandled exception type MalformedURLException
Unhandled exception type IOException
at Test_Class.main(Test_Class.java:6)
import java.net.URL;
import java.util.Scanner;
import java.util.Scanner;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
public class Test_Class {
public static void main(String[] args) {
final String URL = "http://www.java-forum.org/641003-post3.html";
Scanner sc = null;
try {
sc = new Scanner(new URL(URL).openStream(), "ISO-8859-1");
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (sc != null) {
while (sc.hasNextLine()) {
String s = sc.nextLine();
if (s.contains("Beiträge")) {
System.out.println(s.trim());
break;
}
}
}
}
}
Beiträge
<div class="smallfont">
<br />
<div>Registriert seit: 02.05.2010</div>
<div>
Beiträge: 38
</div>
<div>Abgegebene Danke: 1</div>
<div>
Erhielt 0 Danke für 0 Beiträge
</div>