Python "with " statement and Java "Try with resources"