[java]代码库
if(arg0.getSource()==menuItem1){
JFileChooser jch=new JFileChooser();
jch.showOpenDialog(this);//打开文件的对话框
System.out.print(jch.getSelectedFile());
String fileName=jch.getSelectedFile().toString();
try{
BufferedReader br = new BufferedReader
(new InputStreamReader(
new FileInputStream(jch.getSelectedFile())));
for (String line = br.readLine(); line != null; line = br.readLine())
{jta.append(line);
jta.append("\n");
}
br.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
JOptionPane.showMessageDialog(null,e1.getMessage(), "",JOptionPane.CLOSED_OPTION);
//e1.printStackTrace();
}
}