2010-05-06 25 views
-1
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

什么是错误? – 2010-05-06 09:34:30

+0

File file = new File(+ humanName“.txt”); 卡在这里,它假设读取我的输入并删除文件我wan to – user334101 2010-05-06 09:35:54

回答

1

嗯,这行看起来可疑入手:

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

您是不是要找:

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

很难说怎么当你不修复“这个错误”不要说错误是什么,你的标题的“删除方法”也没有意义。

+0

对不起,我的英文很烂,你的方法很好!谢谢 – user334101 2010-05-06 09:40:16

相关问题