I have method
private void writeObject(ObjectOutputStream oos) throws IOException 
In body I write keySet of some HashMap
        for(E e : map.keySet()) {
        oos.writeObject(e);
    }
And it's look OK But if I want to replase this code on
map.forEach((k, v) -> oos.writeObject(k));
I have to surround it with try/catch. Like this
        map.forEach((k, v) -> {
        try {
            oos.writeObject(k);
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
And I can't understand for what
Update I can't understand why I need to processed exception in method body if I anounce in method title that I want it to throw away.
 
     
    