⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filedemo.java

📁 JAVA编程思想源代码 值得一下 很难找的
💻 JAVA
字号:
package chapter10;

import java.io.File;
import java.util.Date;

public class FileDemo {

	public static void main(String[] args) {
		File f1 = new File("C:\\test.txt");
		File newName = new File("C:\\newName.txt");
		System.out.println("f1的长度为:" + f1.length());
		System.out.println("f1的上一级目录为:" + f1.getParent());
		Date d = new Date();
		d.setTime(f1.lastModified());
		System.out.println("f1最近一次修改的时间:" + d);
		System.out.println("f1是否可读:" + f1.canRead());
		System.out.println("f1是否可写:" + f1.canWrite());
		f1.renameTo(newName);
		System.out.println("f1的名字变更为:" + newName.getName() + ",f1是否存在:"
				+ f1.exists());
		newName.delete();
		System.out.println("newName被删除,newName是否存在:" + f1.exists());

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -