如何在java中打开文件

时间:2014-03-25 11:33:48

标签: java file

我想打开一个文件。我一步一步地使用教程,但它不起作用。它显示一个窗口,其中包含有关编译错误的信我不知道哪里出错了。我应该改变什么?

private void otworzActionPerformed(java.awt.event.ActionEvent evt) {                                       
int odpowiedz = jFileChooserotworz.showOpenDialog(this);
      if (odpowiedz == jFileChooserotworz.APPROVE_OPTION) {
          File file = jFileChooserotworz.getSelectedFile();
          try {
              Text.read( new FileReader( file.getAbsolutePath() ), null );
          } catch (IOException e) {
              System.out.println("Nie mogę otworzyć pliku: "+file.getAbsolutePath());
              System.out.println("Problem: "+e);
          }
      }
}             

0 个答案:

没有答案