Sha*_*mar 5 java eclipse file-io
我在 Eclipse 中有一个小型 Java 项目。该项目有一个 src 和 bin 文件夹(典型),并将 src 添加到类路径中。我在 Windows 上运行。
以下调用有效:
System.out.println(TestINI.class.getResource("happytest.ini"));
Run Code Online (Sandbox Code Playgroud)
它打印文件的路径:
file:/D:/work/baton/Touch/JTouch/bin/com/interra/tests/happytest.ini
Run Code Online (Sandbox Code Playgroud)
我检查了上面提到的ini文件的内容是否有预期的内容。
但是从文件中读取如下:
InputStream is = TestINI.class.getResourceAsStream("happytest.ini");
Run Code Online (Sandbox Code Playgroud)
给我一个没有内容的输入流。即它返回一个零字节的文件。
我的 Eclipse 是在 Windows 7 上运行的 3.6 Helios 64 位。
谷歌搜索揭示了资源路径或输入流为空的情况,但我的情况并非如此。
类路径条目如下:
<classpathentry kind="src" path="src"/>
... other class path entries for libraries like ini4j
<classpathentry kind="output" path="bin"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1761 次 |
| 最近记录: |