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

📄 fileinfo.java

📁 主要是java书上的一些代码
💻 JAVA
字号:
//: FileInfo.java

//package g3ds.joop.ch7;

import java.io.*;

public class FileInfo{
	File fileToCheck;

	public static void main(String[] args) throws IOException{
		if (args.length>0){
			for (int i=0;i<args.length;i++){ 
				File fileToCheck = new File(args[i]);
				info(fileToCheck);
			}
		} 
		else{
			File fileToCheck = new File("FileInfo.java"); 
			info(fileToCheck);
		}
	}

	public static void info(File f) throws IOException{
		System.out.println("文件名: \t"+f.getName());
		System.out.println("绝对路径: \t"+f.getAbsolutePath());
		
		if (f.exists()){
			System.out.println("File exists."); 
			System.out.print((f.canRead() ?"and is Readable ":""));
			System.out.print((f.canWrite()?"and is Writeable":""));
			System.out.println("."); 
			System.out.println("File is " + f.length() + " bytes."); 
		}
		else {
			System.out.println("File does not exist.");
		}
	}
}

⌨️ 快捷键说明

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