个VB.App.path,那个就是VB里得到当前目录的一个常量,java中像这样的东西有太多,下边是我自己学的,
以及在网上搜集的多种得到当前工作目录的方法,奉献给大家:
下面的test程序会有些帮助
package tools.tuz.demo
import java.io.File
public class CurrentDirectory {
public static void main(String[] args) throws Exception {
System.out.println(
Thread.currentThread().getContextClassLoader().getResource(""))
System.out.println(CurrentDirectory.class.getClassLoader().getResource(""))
System.out.println(ClassLoader.getSystemResource(""))
System.out.println(CurrentDirectory.class.getResource(""))
System.out.println(CurrentDirectory.class.getResource("/"))
System.out.println(new File("").getAbsolutePath())
System.out.println(System.getProperty("user.dir"))
}
}