有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

当通过JFileChooser获取java文件时,java文件可以被篡改吗?

我正在尝试制作自己的二进制编辑器。我刚刚读完了有关的教程 Netbeans介绍了如何添加JFileChooser,但不知道如何通过它将txt文件转换为二进制文件。这是netbeans网站上的代码

private void OpenActionPerformed(java.awt.event.ActionEvent evt) {
int returnVal = fileChooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fileChooser.getSelectedFile();
    try {
      // What to do with the file, e.g. display it in a TextArea
      textarea.read( new FileReader( file.getAbsolutePath() ), null );
    } catch (IOException ex) {
      System.out.println("problem accessing file"+file.getAbsolutePath());
    }
} else {
    System.out.println("File access cancelled by user.");
}
} 

在将文件写入文本区域之前,如何转换文件


共 (0) 个答案