#fixed code
                                public void truncate() throws IOException{
        RandomAccessFile tempFile = new RandomAccessFile(file, "rw");
        tempFile.setLength(0);
        tempFile.close();
    }
#vulnerable code 
                                public void truncate() throws IOException{
        new RandomAccessFile(file, "rw").setLength(0);
    } 
                            #location 2 
                            #vulnerability type RESOURCE_LEAK