package joeho.net.csdn.blog.io;
import java.io.*;
public class FileTest {
/**
* Method main
*
*
* @param args
*
*/
public static void main(String[] args) throws IOException {
File f = new File("test.txt");
if(f.exists()){
f.delete();
}
else{
f.createNewFile();
}
System.out.println(f.getName());
System.out.println(f.getAbsolutePath());
System.out.println(f.getParentFile());
System.out.println(f.canWrite()?"Canwrite":"not Canwrite");
}
}
本文提供了一个Java程序示例,展示了如何使用File类创建、删除文件及获取文件属性等基本操作。

被折叠的 条评论
为什么被折叠?



