Java 現在のパス取得方法を徹底解説!
在Java中,可以使用System.getProperty(“user.dir”)来获取当前工作目录的路径。示例如下:
public class GetCurrentPath {
public static void main(String[] args) {
String currentPath = System.getProperty("user.dir");
System.out.println("Current working directory is: " + currentPath);
}
}
このプログラムを実行すると、現在の作業ディレクトリのパスが表示されます。