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.");
}
}
}我想在控制台发出文件路径和文件名的信息命令,在DOS下会的,在eclipse下就不知道应该怎么弄了,哪位帮下忙,由于初学者,是消费者,所以比较穷,分数少,只能给5分了,问问题不容易,等我成为高手再散分给大家,呵呵,谢谢哈~~

解决方案 »

  1.   

    右键主类文件,在弹出的菜单中点击
    run...
    弹出一个大框,看见Arguments选项卡了吧
    输入参数就行了。
      

  2.   

    修改补充一下:右键主类文件,在弹出的菜单中点击 
    run as->
    run... 
    弹出一个大框,看见Arguments选项卡了吧 
    在Program arguments
    输入参数就行了。