dcsimg

How do I initialize a JTextArea from an input file?

John Zukowski

The JTextComponent provides a read() method to initialize the text component:

    JTextArea ta = new JTextArea();
    Reader reader = new FileReader(filename);
    ta.read(reader, null);
The second parameter is a description.