Topic: [hlep] 运行java 打开文件, 找不到

  Print this page

1.[hlep] 运行java 打开文件, 找不到 Copy to clipboard
Posted by: potomac
Posted on: 2004-02-24 11:44

请问在jbuilder 中, abc.txt 放在哪里, 才能被程序找到呢?

package ab.cd.ef;
import java.io.*;

public class Untitled2 {
public Untitled2() {
}

public static void main(String[] args) {

FileInputStream fis = null;
try {
fis = new FileInputStream ("abc.txt");
System.out.println("Open Files Success ");
} catch (FileNotFoundException e) {
System.out.println("e.getMessage() = "+e.getMessage());
e.printStackTrace();
}

}
}
这是jbuilder 的运行命令

D:\JBuilder9\jdk1.4\bin\javaw -classpath
"F:\wanggq\Success\classes;
D:\JBuilder9\jdk1.4\demo\jfc\Java2D\Java2Demo.jar;
D:\JBuilder9\jdk1.4\demo\plugin\jfc\Java2D\Java2Demo.jar;
D:\JBuilder9\jdk1.4\jre\lib\charsets.jar;
D:\JBuilder9\jdk1.4\jre\lib\ext\dnsns.jar;
D:\JBuilder9\jdk1.4\jre\lib\ext\ldapsec.jar;
D:\JBuilder9\jdk1.4\jre\lib\ext\localedata.jar;
D:\JBuilder9\jdk1.4\jre\lib\ext\sunjce_provider.jar;
D:\JBuilder9\jdk1.4\jre\lib\im\indicim.jar;
D:\JBuilder9\jdk1.4\jre\lib\jaws.jar;
D:\JBuilder9\jdk1.4\jre\lib\jce.jar;
D:\JBuilder9\jdk1.4\jre\lib\jsse.jar;
D:\JBuilder9\jdk1.4\jre\lib\rt.jar;
D:\JBuilder9\jdk1.4\jre\lib\sunrsasign.jar;
D:\JBuilder9\jdk1.4\lib\dt.jar;
D:\JBuilder9\jdk1.4\lib\htmlconverter.jar;
D:\JBuilder9\jdk1.4\lib\tools.jar" ab.cd.ef.Untitled2

2.Re:[hlep] 运行java 打开文件, 找不到 [Re: potomac] Copy to clipboard
Posted by:
Posted on: 2004-02-29 07:35

基本上是和程式在同一个文件內。

3.Re:[hlep] 运行java 打开文件, 找不到 [Re: potomac] Copy to clipboard
Posted by: newnewworm
Posted on: 2004-02-29 09:50

把包的路径加进去
然后把文件放入包内......

4.Re:[hlep] 运行java 打开文件, 找不到 [Re: potomac] Copy to clipboard
Posted by: kuramantboy
Posted on: 2004-03-02 02:04

好像放在项目对应的目录里面

5.Re:[hlep] 运行java 打开文件, 找不到 [Re: potomac] Copy to clipboard
Posted by: robin
Posted on: 2004-03-05 11:20

放在你的classpath里面就可以了!

6.Re:[hlep] 运行java 打开文件, 找不到 [Re: potomac] Copy to clipboard
Posted by: jameszhang
Posted on: 2004-03-05 11:28

放到System.getProperty("user.dir");下

7.Re:[hlep] 运行java 打开文件, 找不到 [Re: kuramantboy] Copy to clipboard
Posted by: potomac
Posted on: 2004-03-05 12:00

kuramantboy wrote:
好像放在项目对应的目录里面


正确 !


/* etSystemProperties.java */
import java.util.Properties;

public class GetSystemProperties {
public static void main(String args[]) {
Properties prop = new Properties(System.getProperties());
prop.list(System.out);
}
}

====output ====
java.runtime.name=Java(TM) 2 Runtime Environment, Stand...
sun.boot.library.path=D:\JBuilder9\jdk1.4\jre\bin
java.vm.version=1.4.1_02-b06
...
sun.os.patch.level=Service Pack 3
java.vm.specification.name=Java Virtual Machine Specification
user.dir=F:\wanggq\TestReturn //这里放要打开的文件
...

8.Re:[hlep] 运行java 打开文件, 找不到 [Re: potomac] Copy to clipboard
Posted by: kjjx
Posted on: 2004-04-06 00:15

ab/cd/ef和ab放在同级目录

9.Re:[hlep] 运行java 打开文件, 找不到 [Re: potomac] Copy to clipboard
Posted by: pengtaoli
Posted on: 2004-04-22 10:15

程序运行的目录应该没问题。
我想放在path里应该可以找到


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923