文件的删除! 怎么删除文件啊?我问了一个人,那人说先得定位,看文件在什么地方!然后删除!到底怎么做啊!我做的是一个系统,有上传上来的文件,现在要我做删除这个功能! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 File f = new File(FilePathAndName);f.delete();当然需要知道文件在什么地方了! import java.text.*;import java.util.*;import java.io.*;public class ghytest { public static String getYearMonthDayOfchina(String type) { SimpleDateFormat ghyghost = new SimpleDateFormat(type); return ghyghost.format(new Date()); } public static void main(String[] args) {File ghy=new File("c:\1.txt");if (ghy.exists()) {ghy.delete(); System.out.print("OK"); } else { System.out.print("no"); } }}我写了一个实例,但删除不了c:\1.txt怎么办? File ghy=new File("c:\1.txt");----------------你这种写法编译都通不过怎么删? import java.text.*;import java.util.*;import java.io.*;public class ghytest { public static String getYearMonthDayOfchina(String type) { SimpleDateFormat ghyghost = new SimpleDateFormat(type); return ghyghost.format(new Date()); } public static void main(String[] args) {File ghy=new File("c:","1.txt");System.out.print(ghy.getName());if (ghy.exists()) {ghy.delete(); System.out.print("OK"); } else { System.out.print("no"); } }}楼主这样OK File ghy=new File("c:/1.txt");File ghy=new File("c:\\1.txt");这样都可以的 JAVA里“\”是转义符,所以要用二个才行,File ghy=new File("c:\\1.txt"); 关于鼠标移动的侦听 学生选课系统表的设计 关于 list 的赋值 读文件 怎么在Jtable中的同一列的不同的jcomboBox 从键盘接收十个整数。 比较大小后输出最大的和最小的怎么实现? JAVA程序员高级群 eclipse + tomcat做servlet时的web.xml文件是如何配置? MS SQL的插入语句(JAVA中)(可以多补分,只要能解决) 请教高手:有没有关于java实现加密方面的例程或站点,如用户输入后,点击按钮后,用java 加密。 谁能帮我解决一下以下AWT程式的问题?重分答谢! 今天去面试的一道题目大家看看对不!
f.delete();
当然需要知道文件在什么地方了!
import java.util.*;
import java.io.*;public class ghytest { public static String getYearMonthDayOfchina(String type) {
SimpleDateFormat ghyghost = new SimpleDateFormat(type);
return ghyghost.format(new Date());
} public static void main(String[] args) {
File ghy=new File("c:\1.txt");
if (ghy.exists())
{ghy.delete();
System.out.print("OK");
}
else
{
System.out.print("no");
}
}}我写了一个实例,但删除不了c:\1.txt怎么办?
----------------
你这种写法编译都通不过怎么删?
import java.util.*;
import java.io.*;public class ghytest { public static String getYearMonthDayOfchina(String type) {
SimpleDateFormat ghyghost = new SimpleDateFormat(type);
return ghyghost.format(new Date());
} public static void main(String[] args) {
File ghy=new File("c:","1.txt");
System.out.print(ghy.getName());
if (ghy.exists())
{ghy.delete();
System.out.print("OK");
}
else
{
System.out.print("no");
}
}}
楼主这样OK
File ghy=new File("c:\\1.txt");这样都可以的