how to import a Text file content to a JTextArea in a Java application using JFileChooser?
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser jf = new JFileChooser();
final JEditorPane document = new JEditorPane();
int returnval=jf.showDialog(this, null);
File file = null;
if(returnval == JFileChooser.APPROVE_OPTION)
file = jf.getSelectedFile();
String str ;
try {
byte bt[]= Files.readAllBytes(file.toPath());
str=new String(bt,"UTF-8");
System.out.println(str);
} catch (IOException ex) {
Logger.getLogger(test.class.getName()).log(Level.SEVERE, null, ex);
}
}