fileinfo.java
来自「《Java核心技术应用开发》电子工业出版社书籍源代码」· Java 代码 · 共 28 行
JAVA
28 行
package sample;
import java.io.*;
public class FileInfo{
public void info(File f) throws IOException{
System.out.println("Name: " + f.getName());
System.out.println("Path: " + f.getAbsolutePath());
if(f.exists()){
System.out.println("File is there");
System.out.println("File can read? " + f.canRead());
System.out.println("File can write? " + f.canWrite());
System.out.println("File length is: " + f.length());
}
else
System.out.println("File doesn't exist");
}
public static void main(String[] args) throws IOException {
if(args.length > 0){
for(int i = 0; i<args.length; i++){
File file = new File(args[i]);
new FileInfo().info(file);
}
} else
System.out.println("No file to check!");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?