In the following code, I wrote throws in the method signature, but again in Lambda for write, the compiler gives an error. Why?
compiler error: Unhandled exception: java.io.IOException
public void saveTodoItems() throws IOException {
try (BufferedWriter outputStream = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("TodoItems.txt"), StandardCharsets.UTF_8))) {
todoItems.forEach(todoItem -> {
outputStream.write(todoItem.getShortDescription() + "\t" //compile error on write
+ todoItem.getDetail() + "\t"
+ todoItem.getDeadLine()+"\n");
});
}
}