开发者

getResourceStream for writing files

For javame.

Since getResourceAsStream() is for reading files, is there a getResourceAsStream() equivalent for output st开发者_如何学JAVAream / writing files?

Note: the file is inside the project's folders and will soon be packaged into a jarfile.


getResoureAsStream() deals with resources. Returning an output stream doesn't make sense because that implies you are trying to overwrite your resources on the fly.

Besides, for most resources residing in a JAR or remote locations, you can't write to it anyway.


It would not make sense to have that.
What would the getResourceAsStream get, since the resource does not exist yet?

In addition getResourceAsStream is typically used to access a file within a JAR or WAR, you cannot write there.

getResourceAsStream is typically used to load configuration and properties files.
Here is a good tutorial (a little dated) on how to use it.


Yes. create a File-Object and then call getOutputStream on this file object.


FileOutputStream is also available for java me.

FileOutputStream out = new FileOutputStream("output.txt");
out.write( ... );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜