I am browsing a .txt file in java... How to extract the contents in that text file ?
My source code for browsing .txt file is:
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
public boolean accept(File f) {
return f.getName().toLowerCase().endsWith(".txt")
|| f.isDirectory();
}
public String getDescription() {
return ".txt Files";
}
});
int r = chooser.showOpenDialog(new JFrame());
if (r == JFileChooser.APPROVE_OPTION) {
String name = chooser.getSelectedFile().getName();
jTextField3.setText(name);
}
else
{
JOptionPane.showMessageDialog(null,
"You must select one Audieo File to be the reference.", "Aborting...",
JOptionPane.WARNING_MESSAGE);
}