请问怎么用JAVA的IO操作实现文件的删除?

lywei123 2004-04-14 06:11:23
rt!
...全文
28 5 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
lywei123 2004-04-14
谢谢大家的帮助!
  • 打赏
  • 举报
回复
zijibense 2004-04-14
楼主,zbsk(sophie)答得差不多了吧
  • 打赏
  • 举报
回复
lostyq 2004-04-14
delete
public boolean delete()
Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a directory, then the directory must be empty in order to be deleted.

Returns:
true if and only if the file or directory is successfully deleted; false otherwise
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkDelete(java.lang.String) method denies delete access to the file
  • 打赏
  • 举报
回复
zbsk 2004-04-14
import java.io.*;
public class Del
{
public static void main(String[] args)
{
File f = new File("c:/a.txt");
f.delete();
}
}
  • 打赏
  • 举报
回复
zbsk 2004-04-14
File里的delete()方法
  • 打赏
  • 举报
回复
发帖
Java SE

6.2w+

社区成员

Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
帖子事件
创建了帖子
2004-04-14 06:11
社区公告
暂无公告