java - 'try with resource' feature for File class -


i have 1 scenario trying implement java 7 'try resource' feature.

my block contains object of bufferedwriter , file, want close using 'try resource' feature, instead of closing calling close method explicitly.

but checked on net , saw file class not implement autocloseable interface, bufferedwriter does. how can manage scenario implement 'try resource' feature?

 try (bufferedwriter br = new bufferedwriter(new filewriter(path)))  

use simply, br closed automatically. eg. http://www.roseindia.net/java/beginners/java-write-to-file.shtml


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -