Java得到类目录

String path = MainTest.class.getResource("").getPath();//得到当前类class的目录

String binPath = MainTest.class.getResource("").getPath();//得到当前类class的目录

String appPath= new File(binPath).getParentFile().getAbsolutePath()//当前的工程目录

你可能感兴趣的:(java)