我想读取文件的路径。我发现的所有内容都是关于类文件,如何读取文件或如何在这个方向上保存文件。读取文件方向/路径Java
但我想要的是显示我这样的路径的方法:
C:/用户/管理员/文件/的NetBeansProjects/HashmapDemo/HeaderTemplate中
,这样我可以保存这个方向在一个XML文件中。
我希望我的意思是可以理解的,我倾向于写无人能理解的东西。
我已经试过:
public static String getCleanPath() {
ClassLoader classLoader = XmlLoader.class.getClassLoader();
File classpathRoot = new File(classLoader.getResource("").getPath());
return classpathRoot.getPath();
}
到目前为止,但就像我说的,它不给我,我需要的信息。
这正是我搜索过的内容! 非常感谢! – 2014-11-04 12:45:18