2012-09-24 36 views

回答

4

使用

String AbsolutePath = new File(".").getAbsolutePath(); 

说明:File(".")代表当前目录和getAbsoultePath()回报绝对路径到当前目录。

希望它有帮助:-)

1

此调用:new File(".").getAbsolutePath()为您提供应用程序的当前工作目录。我希望这回答了你的问题。

4

我会用

String logPath = new File(".").getAbsolutePath(); 

..可以启动。

+0

其实我将这个值传递给数据库中的表。当我使用这种方法时,该值被带到数据库。 – Gapchoos

+1

好的,恭喜,但它完全不相关:)你可以用这个字符串做任何你想做的事情。例如,你甚至可以发送它。 –

+0

当我以这种方式给出路径时,仍然不会获得表格字段日志路径。 propertyInterface.addProperty( “日志路径”,LOGPATH);这是我做到的。但是,当我硬编码日志路径的值,它的工作。 – Gapchoos

1

您正在使用哪种语言?

的Java:

File directory = new File ("."); 
System.out.println ("Current directory's canonical path: " +  directory.getCanonicalPath()); 
System.out.println ("Current directory's absolute path: " + directory.getAbsolutePath());