java获取当前目录及父目录和兄弟目录

时间:2022-01-06 22:27:08
import java.io.*;

public class test{
    public static void main(String[] args) {
                // get current dir
		File file = new File(System.getProperty("user.dir"));
		// get parent dir
		String parentPath = file.getParent(); 
		#System.out.println(parentPath);
		// get brother dir
		String toolPath = parentPath + "/tool";
		#System.out.println(toolPath);
    }
}