我可以知道如何修复此错误吗?是删除方法

时间:2010-05-06 09:30:09

标签: java

import javax.swing.*;
import java.io.File;

public class Third {

    public static void main(String[] args)  throws Exception {
        String humanName; 

        humanName = JOptionPane.showInputDialog(null, "Enter the file name");
        File file = new File(+ humanName".txt");
        System.out.println(file.delete());
        JOptionPane.showMessageDialog(null, "File deleted" + humanName);
    }

}

1 个答案:

答案 0 :(得分:1)

这条线看起来很可疑:

File file = new File(+ humanName".txt");

你的意思是:

File file = new File(humanName + ".txt");

当你没有说出错误是什么时,很难说如何解决“这个错误”,你的标题的“删除方法”也没有意义。

相关问题