import java.io.*; class IOUse{
static File fileToCheck; public static void main(String args[]) throws IOException{
if(args.length>0){
for(int i=0;i <args.length;i++){
//实例化文件对像
fileToCheck=new File(args[i]);
info(fileToCheck);
}
}
else{
System.out.println("No file given.");
}
}
public static void info(File f) throws IOException{
//打印文件信息
System.out.println("Name: "+f.getName());
System.out.println("Path: "+f.getPath());
if(f.exists()){
System.out.println("File exists.");
System.out.println((f.canRead()?"and is readable":""));
System.out.println((f.canWrite()?"and is Writeable":""));
System.out.println(".");
System.out.println("File is "+f.length()+"bytes.");
}
else{
System.out.println("File does not exists.");
}
}
}
不知道eclipse下如何在控制台发出命令,就是相当于在DOS里的 java IOUse e:\aaa.txt的命令,帮忙下,谢谢了~~~
static File fileToCheck; public static void main(String args[]) throws IOException{
if(args.length>0){
for(int i=0;i <args.length;i++){
//实例化文件对像
fileToCheck=new File(args[i]);
info(fileToCheck);
}
}
else{
System.out.println("No file given.");
}
}
public static void info(File f) throws IOException{
//打印文件信息
System.out.println("Name: "+f.getName());
System.out.println("Path: "+f.getPath());
if(f.exists()){
System.out.println("File exists.");
System.out.println((f.canRead()?"and is readable":""));
System.out.println((f.canWrite()?"and is Writeable":""));
System.out.println(".");
System.out.println("File is "+f.length()+"bytes.");
}
else{
System.out.println("File does not exists.");
}
}
}
不知道eclipse下如何在控制台发出命令,就是相当于在DOS里的 java IOUse e:\aaa.txt的命令,帮忙下,谢谢了~~~
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货