package com.dataStructure.graph;
import java.io.*;
import java.util.Scanner;
public class PathTest {
public PathTest(){
// 获取 class 加载的根路径
// C:\Users\rHotD\IdeaProjects\Data-Structure-and-Algorithm-Analysis-by-Java
// \out\production\Data-Structure-and-Algorithm-Analysis-by-Java
File a = new File(this.getClass().getResource("/").getPath());
System.out.println(a.toString());
// 获取当前 class 的所在 project 路径
// C:\Users\rHotD\IdeaProjects\Data-Structure-and-Algorithm-Analysis-by-Java
// \out\production\Data-Structure-and-Algorithm-Analysis-by-Java
// \com\dataStructure\graph
File b = new File(this.getClass().getResource("").getPath());
System.out.println(b.toString());
}
public static void main(String[] args) throws IOException {
PathTest pathTest = new PathTest();
// 获取 project 路径
// C:\Users\rHotD\IdeaProjects\Data-Structure-and-Algorithm-Analysis-by-Java
File c = new File("");
System.out.println(c.getCanonicalPath());
}
}