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);
}
}
答案 0 :(得分:1)
这条线看起来很可疑:
File file = new File(+ humanName".txt");
你的意思是:
File file = new File(humanName + ".txt");
当你没有说出错误是什么时,很难说如何解决“这个错误”,你的标题的“删除方法”也没有意义。