由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Jar文件中的data
相关主题
How to protect Jar files from being decompiled?Jar question
help! string format???Open Jar
问个菜鸟问题,关于JAVA中写文件的应该做成哪类包?
[转载] 有用Eclipse的嘛?入门Java CLASSPATH问题:
[合集] How to check whether a file is locked?jar file question
如何关闭打开的输入输出?Ant and Netbeans help
问一个blocking IO的程序makefile to set classpath
Re: [转载] Re: .jar文件是怎么产生的?How to delete an entry in JAR?
相关话题的讨论汇总
话题: jar话题: filewriter话题: file话题: getclass
进入Java版参与讨论
1 (共1页)
I***e
发帖数: 1136
1
I have a few classes accessing a "data.txt" file. I want to create a .jar file
and package everything in. However, how do I point to the data.txt file
inside the jar?
If it is outside I can easily use something like
FileWriter fw=new FileWriter("C:\\data.txt");
Now what should I do?
Thanks.
-iCare-
g**********y
发帖数: 14569
2
Use getClass().getResource("/data.txt"); if data.txt is in the top level of
JAR. If you want to visit it from same level of class, then getClass().
getResource("data.txt");

file

【在 I***e 的大作中提到】
: I have a few classes accessing a "data.txt" file. I want to create a .jar file
: and package everything in. However, how do I point to the data.txt file
: inside the jar?
: If it is outside I can easily use something like
: FileWriter fw=new FileWriter("C:\\data.txt");
: Now what should I do?
: Thanks.
: -iCare-

I***e
发帖数: 1136
3
Great! Thanks.

【在 g**********y 的大作中提到】
: Use getClass().getResource("/data.txt"); if data.txt is in the top level of
: JAR. If you want to visit it from same level of class, then getClass().
: getResource("data.txt");
:
: file

1 (共1页)
进入Java版参与讨论
相关主题
How to delete an entry in JAR?[合集] How to check whether a file is locked?
where to get struts 1.0?如何关闭打开的输入输出?
[转载] Problems with reading image file in Jar.问一个blocking IO的程序
请教:Junit fails as an Ant taskRe: [转载] Re: .jar文件是怎么产生的?
How to protect Jar files from being decompiled?Jar question
help! string format???Open Jar
问个菜鸟问题,关于JAVA中写文件的应该做成哪类包?
[转载] 有用Eclipse的嘛?入门Java CLASSPATH问题:
相关话题的讨论汇总
话题: jar话题: filewriter话题: file话题: getclass