import java.awt.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
public class FileToVector {
private JScrollPane getContent() {
Vector<String> vector = new Vector<String>();
JTextArea textArea = new JTextArea();
File file = new File("FileToVector.java");
Scanner scanner = null;
try {
scanner = new Scanner(file);
} catch(FileNotFoundException e) {
System.out.println("file not found: " + e.getMessage());
}
while(scanner.hasNextLine()) {
String line = scanner.nextLine();
vector.addElement(line);
}
scanner.close();
for(int j = 0; j < vector.size(); j++)
textArea.append(vector.get(j) + "\n");
return new JScrollPane(textArea);
}
public static void main(String[] args) {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new FileToVector().getContent());
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
}
}