| Office: | Albertus Hall 400-2 |
|---|---|
| Office Hours: | Monday 2:30-4:00pm, Tuesday 1:00-2:30pm |
| Email: | click here to email me |
| Phone: | 518-485-3755 (on campus x3755) |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
public class ReadFromWeb
{
public static void main(String[] args)
{
URL url = null;
// Read a data file from a Web site and
// display to user
try { // URL from WEEK 13 ASSIGNMENT
url = new URL( "http://academic2.strose.edu/math_and_science/goldschd/docs/NYPopulationData.txt" );
InputStream input = url.openStream();
InputStreamReader isr = new InputStreamReader(input);
BufferedReader br = new BufferedReader(isr);
while ( br.ready() ) {
String line = br.readLine();
System.out.println( line );
}
}
catch( MalformedURLException ex )
{
System.out.println( "Invalid URL detected." );
System.exit( 1 );
}
catch ( IOException ex )
{
System.out.println( "I/O Problem." );
System.exit( 1 );
}
}
}
// Much of this code was automatically generated by JDeveloper
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
public class EditorPaneExample extends JFrame {
private JEditorPane jEditorPane1 = new JEditorPane();
public EditorPaneExample() {
try {
jbInit();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
EditorPaneExample editorPaneExample = new EditorPaneExample();
}
private void jbInit() throws Exception {
// jEditorPane1.setPage( "http://academic2.strose.edu/math_and_science/goldschd/docs/NYPopulationData.txt" );
jEditorPane1.setPage( "http://www.rpi.edu" );
// this.getContentPane().add(jEditorPane1, null);
JScrollPane p1 = new JScrollPane(jEditorPane1);
this.getContentPane().add(p1, null);
this.setSize( 500, 400 );
this.setVisible( true );
}
}