change the try-with-resource to try-catch-finally