我在spring服务层有这个方法。但它无法写入文件,也没有例外。我的代码出了什么问题?
public void addLineToFile(String file, String line) {
try {
ClassPathResource cpr = new ClassPathResource(file);
FileOutputStream outputStream = new FileOutputStream(cpr.getFile());
outputStream.write(line.getBytes());
outputStream.close();
} catch (FileNotFoundException ex) {
Logger.getLogger(CustomerToFile.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(CustomerToFile.class.getName()).log(Level.SEVERE, null, ex);
}
}