//Retrieve XML from web
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
public class MainClass {
public static void main(String[] args){
try {
URL url = new URL("http://www.services.explorecalifornia.org/rss/tours.php"); //Go and see what is on this link in internet explorer. It's an xml file.
StringBuilder sb = new StringBuilder();
InputStream is = url.openStream();
int c;
while (true){
if ((c = is.read()) == -1){
break;
}
else{
sb.append((char)c);
}
}
System.out.println(sb);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
public class MainClass {
public static void main(String[] args){
try {
URL url = new URL("http://www.services.explorecalifornia.org/rss/tours.php"); //Go and see what is on this link in internet explorer. It's an xml file.
StringBuilder sb = new StringBuilder();
InputStream is = url.openStream();
int c;
while (true){
if ((c = is.read()) == -1){
break;
}
else{
sb.append((char)c);
}
}
System.out.println(sb);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment