h3 { margin-top: 0.46cm; margin-bottom: 0.46cm; line-height: 173%; page-break-inside: avoid; }h3.western { font-family: "DejaVu Serif",serif; font-size: 16pt; }h3.cjk { font-family: "DejaVu Sans"; font-size: 16pt; }h3.ctl { font-family: "DejaVu Sans"; font-size: 16pt; }p { margin-bottom: 0.21cm; }
File 类是io 包中唯一代表文件本身 而非代表文件内容的类
File 类定义了一些与平台无关的方法来操纵文件 如创建,删除,重命名文件
Java 中的目录被当做一种特殊的文件使用 list 方法可以返回目录中的所有子目录和文件名
在Unix 下路径分割符为/ dos 下路径分割符为 / java 可以正确处理dos 的路径和unix 的路径
例子判断某个文件是否存在 存在则删除 不存在则创建
File file = new java.io.File( "1.txt" );
if (file.exists()){
file.delete();
} else {
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}