【发布时间】:2011-03-28 20:20:54
【问题描述】:
这是我的代码
public String path;
public String fileName;
public static void readData() throws IOException{
try {
path="myPath"
fileName="myFileName";
fstream = new FileInputStream(path+fileName);
br = new BufferedReader(new InputStreamReader(fstream));
//do something...//
}
br.close();
} catch (FileNotFoundException ex) {
JOptionPane.showMessageDialog(null, "Reading file error");
Logger.getLogger(LeggiDaFile.class.getName()).log(Level.SEVERE, null, ex);
}
}
我想知道如何检查 fstream 是否存在。如果它不存在,则必须创建一个新文件。我怎样才能做到这一点? 谢谢
【问题讨论】: