Java 实例 - 删除文件
Java 教程
· 2019-02-10 20:27:13
以下实例演示了使用 delete() 方法将文件删除:
Main.java 文件
import java.io.*;
public class Main
{
public static void main(String[] args)
{
try{
File file = new File("c:\\test.txt");
if(file.delete()){
System.out.println(file.getName() + " 文件已被删除!");
}else{
System.out.println("文件删除失败!");
}
}catch(Exception e){
e.printStackTrace();
}
}
}
以上代码运行输出结果为(需要在 C 盘上先创建 test.txt 文件):
test.txt 文件已被删除!
点击查看所有 Java 教程 文章: https://www.codercto.com/courses/l/12.html
Beginning Google Maps API 3
Gabriel Svennerberg / Apress / 2010-07-27 / $39.99
This book is about the next generation of the Google Maps API. It will provide the reader with the skills and knowledge necessary to incorporate Google Maps v3 on web pages in both desktop and mobile ......一起来看看 《Beginning Google Maps API 3》 这本书的介绍吧!