【发布时间】:2017-05-12 09:34:42
【问题描述】:
我目前正在阅读 Java 中的 txt 文件,该文件位于带有扫描仪对象的包中。
为了接收文件位置,我使用了一种快速而肮脏的方法:
File currentDirectory = new File(new File(".").getAbsolutePath());
String location = currentDirectory.getAbsolutePath().replace(".", "")+"\\corefiles\\src\\filereadingexample\\";
- 有更好的方法吗?
我很想改进我的代码。
问候 J
【问题讨论】:
-
是的。查看资源(使用类路径)