我写了以下方法:
protected void writeCSV(BufferedWriter out, String s) {
try {
out.write('"');
out.write(s.replaceAll("\"", "\"\""));
out.write('"');
out.write(',');
}
catch (IOException e) {
JOptionPane.showMessageDialog(window, "IOException");
}
}
它被称为:
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filePath.toString()), "UTF-8"));
writeCSV(out, "CSV cell");
Eclipse不喜欢这样,并要求我将方法签名中第一个参数的类型更改为Writer
。我知道BufferedWriter
扩展了Writer
,但为什么不被认可为BufferedWriter
?
答案 0 :(得分:0)
Looser指出了我的答案。在out
实例化Writer
之前,BufferedWriter
被简单地声明为{{1}}。咄...