import java.io.*;class  myfile
{
public static void main(String[] args) 
{
File f=new File(args[0]);
//File f=new File("myfile.java");
String path=f.getAbsolutePath();
System.out.println(path);
}
}

解决方案 »

  1.   


    java myfile -myfile.java
    命令行测试
      

  2.   

    同意programdolt(我普普通通,我是个杀猪的)
      

  3.   

    试试这个看行不行import java.io.*;
    import java.util.*;
    public class Search
    {
    //File path=new File("c:\\");
    private  void searchfile(File path,String filename) throws FileNotFoundException,IOException
    {
    File[] filelist=path.listFiles();
    for (int i=0;i<filelist.length;i++)
    {
      if (filelist[i].isDirectory())
        searchfile(filelist[i],filename);
       //System.out.println(filelist[i].getPath());
      else
        {
         if (filelist[i].getName().equals(filename))
         System.out.println(filelist[i].getAbsolutePath());
        
           
           
        }
    }
    }
    public static void main(String[] args)
    {
    Search s=new Search();
    File ff=new File(args[0]);
    try
    {
    s.searchfile(ff,args[1]);
    //System.out.println(args[0]);
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }
    }
    }