English 中文(简体)
档案材料是Null?
原标题:FileInputStream is Null?

因此,这一条线使返回无效。 在创建这一档案的同时,我做了什么错误呢?

FileInputStream fin = new FileInputStream(new File(getClass().getResource("data/levellocks.lv").toURI()));
最佳回答

除非你真的需要文件输入,否则可以简化以下几条:

InputStream in = getClass().getResourceAsStream("data/levellocks.lv");

类别:植被资源与类别。 AsStream与一揽子计划相对应。 为了获得有关班轮根的档案,你可以将这些方法带上班轮:

InputStream in = getClass().getClassLoader().getResourceAsStream("data/levellocks.lv");

你们是否确保档案存放在你的双亲手上,紧接上了class子的档案? 不仅在您的消息来源中,在.案卷的旁边,也不是在你手上?

问题回答

唯一可以取消的事物是获得资源(“数据/级数据”。

要么获得地图集,要么获得资源,要么放弃。 否则,一切都会成功或成为例外。

我实际上刚刚处理过这个问题(我没有专家),但试图弄清,看施工者试图把名字上去。 对我来说,这是这一类的一揽子方案。 因此,当我把档案放在预期的夹中时,它就发现。

你们可能会有不同,因为我用ven子。 但是,我把它放在了北极圈/主要/资源中,却看不到。 当我在 com/主要/资源中设置一个倍数结构时,发现它。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签