package getFile;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.FileReader;


public class GetFileImpl {

    public static void writeInFile(String file, int i) {
        try {
            String str = "New writter type INOUT";
            BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));
            writer.write(str + " " + String.valueOf(i) + "\n");

            writer.close();
        } catch (FileNotFoundException fnfe) {
            fnfe.printStackTrace();
            System.exit(-1);
        } catch (IOException ioe) {
            ioe.printStackTrace();
            System.exit(-1);
        }
    }
    public static void readInFile(String filename) {
        try {
            File file = new File(filename); 
            BufferedReader br = new BufferedReader(new FileReader(file)); 
            String st; 
            while ((st = br.readLine()) != null) {
              System.out.println(st); 
            } 
        } catch (FileNotFoundException fnfe) {
            fnfe.printStackTrace();
            System.exit(-1);
        } catch (IOException ioe) {
            ioe.printStackTrace();
            System.exit(-1);
        }
    }
}

@@ -301,34 +301,16 @@
 nt i) %7B%0A
-        try %7B%0A    
         
@@ -348,36 +348,37 @@
 INOUT%22;%0A        
-    
+try (
 BufferedWriter w
@@ -431,17 +431,19 @@
 , true))
-;
+) %7B
 %0A       
@@ -502,37 +502,8 @@
 n%22);
-%0A%0A            writer.close();
 %0A   
@@ -723,24 +723,25 @@
     %7D%0A    %7D%0A
+%0A
     public s
@@ -797,67 +797,9 @@
 try 
-%7B%0A            File file = new File(filename); %0A            
+(
 Buff
@@ -852,16 +852,31 @@
 der(
-file)); 
+new File(filename)))) %7B
 %0A   
@@ -894,17 +894,16 @@
 ring st;
- 
 %0A       
@@ -956,24 +956,26 @@
             
+  
 System.out.p
@@ -985,17 +985,16 @@
 tln(st);
- 
 %0A       
@@ -999,17 +999,16 @@
        %7D
- 
 %0A       

Fix test 2_get_file to use try with resources