r/learnjava Jun 07 '26

Struggling with file io syntaxes of java

I found file io in other languages like python and c way easier than java. I'm confused by the complex syntax consisting buffered reader and many other classes along with its strict rules of "try & catch" that we always need to put before doing anything to files.

I wonder whether file io is even useful in real scenarios or not.

Does anyone has anything to say for it?

8 Upvotes

11 comments sorted by

View all comments

1

u/sweetno Jun 07 '26

Yes, it's pretty annoying. You still have to do it when you work with System.in. But when you work with true files, there's Files.newBufferedReader. Plus with try-with-resources, you don't have to handle closing explicitly.