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

lywei123 2004-04-14 06:11:23
rt!
...全文
65 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
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()方法

62,630

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧