【发布时间】:2010-12-04 10:01:16
【问题描述】:
你好,我在Eclipse下写了这样一个函数:
public static ArrayList<String> getMails(){
ArrayList<String> mails = new ArrayList<String>();
try{
FileInputStream fstream = new FileInputStream("mails.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
mails.add(strLine.trim());
}
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
return mails;
}
mails.txt 文件位于 workspace/projectname 下,我想将此项目保留在 workspace/projectname/bin/ 目录下,作为相对路径,因此每当我将 workspace/projectname//bin 目录复制到其他位置时或电脑,让它工作。但是,当我尝试这个时,我得到“FileNotFound”异常。我怎样才能解决这个问题 ? 谢谢
【问题讨论】:
标签: java eclipse path classpath