Writing to a text file using try with resourcesJava

Try with resources is available since java 7. So in order to use try with resources we need to go to Project Settings and set language level to 7.