import java.awt.Font; import java.io.IOException; import java.net.URL; import java.util.Scanner; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTextArea; /** * * @author Bill Kraynek * * COP3337 Example */ public class RemoteFileReadExampleWithJTextArea { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { String fileAddress = "http://www.cis.fiu.edu/~kraynek/COP3337-examples/ArrayListMaxExample.java"; URL url = new URL(fileAddress); Scanner fileScanner = new Scanner(url.openStream()); fileScanner.useDelimiter("[^a-zA-Z]+"); String out = ""; while( fileScanner.hasNext() ) { out += " " + fileScanner.next() + "\n"; }// end while Font font = new Font("monospaced",Font.BOLD,20); JTextArea area = new JTextArea(out,30,25); area.setFont(font); JScrollPane scrollPane = new JScrollPane(area); JOptionPane.showMessageDialog(null,scrollPane); } }