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

📄 ch8ex2.java

📁 JAVA程序设计 丁岳伟 彭敦陆编 高等教育出版社 第7---11章程序
💻 JAVA
字号:
import java.io.*;
import java.util.*;
import java.text.*;
public class ch8ex2{
	public static void main(String[]args){
		File f1=new File("ch8ex1.class");
		if(f1.exists()){
			//显示文件属性
			String lo=f1.getAbsolutePath();
			System.out.println("The location is :"+lo);
			long len=f1.length();
			System.out.println("Size is : "+len);
			long mo=f1.lastModified();
			Date d=new Date(mo);
			DateFormat df=DateFormat.getDateTimeInstance(DateFormat.DEFAULT,DateFormat.DEFAULT);
			String fDate=df.format(d);
			System.out.println("Last Modified :"+fDate);
			System.out.print("The attributes: ");
			if(f1.canRead())
				System.out.println("  can read");
			if(f1.canWrite())
				System.out.println("  can write");
			if(f1.isHidden())
				System.out.println("  is hidden");
			//修改文件属性
			f1.setLastModified(mo+1000);
			f1.setReadOnly();
		}else
			System.out.println("ch8ex1.class file is not exist");
	}
}

⌨️ 快捷键说明

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