这是我的代码
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是否存在。如果不存在,就必须创建一个新文件。我该怎么做呢? 谢谢
InputStreamReader
,指定Charset
,而不是使用默认字符集的FileReader
... - Jesse