package jtextareatest; import java.io.FileInputStream; import java.io.IOException; import javax.swing.*; public class Jtextareatest { public static void main(String[] args) throws IOException { FileInputStream in = new FileInputStream("test.txt"); JFrame frame = new JFrame("WHAT??"); frame.setSize(640, 480); JTextArea textarea = new JTextArea(); frame.add(textarea); int c; while ((c = in.read()) != -1) { textarea.setText(textarea.getText() + Integer.toString(c)); } frame.setVisible(true); in.close(); } }
When this runs, instead of placing the correct words from the file, it instead places random numbers that have no relevance to the words. How can I fix this?
test.txt
? – trashgod