JAVA:获得当前执行路径的办法

2022/1/14 17:08:19

本文主要是介绍JAVA:获得当前执行路径的办法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

  比如吾在开发时调试功能,当前路径是哪个?有点明白,也不确定。这个时候,还是老老实实的检查一下:

public static String getCurrentRunningDir()
{
    File f = new File("");
    try
    {
        String dir = f.getCanonicalPath();
        System.out.println("Current Dir:"+dir);
        return dir;
    }
    catch (IOException e)\
    {
         e.printStackTrace();
    }
    return null;
}



这篇关于JAVA:获得当前执行路径的办法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程