我想你该知道你运行的程序的文件名吧!!import java.io.*;
class Hello 
{
public static void main(String[] args) 
{
File file = new File("Hello.java");

System.out.println("The Path is "+file.getAbsolutePath());
}
}

解决方案 »

  1.   

    但是我调用的不是本身的那个文件,而是别的文件,是一个dat的文件
      

  2.   

    class test 
    {
    public static void main(String[] args) 
    {
        String test = System.getProperty("user.dir").replace('\\','/');
        System.out.println(test);
    }
    }
      

  3.   

    用我先说的办法,你就知道了路径。
    他的一样,用System的getProperty 返回当前位置。一样知道了当前路径。你用路径字符串+filename不就是你要调用的名字了吗?
    如果有相对路径一样加上去不得了。