benashby
4/8/2016 - 9:16 PM

fos

 //Before Loop
        FileOutputStream badExportFos = null;
        try {
            badExportFos = new FileOutputStream(new File(System.getProperty("user.home") + "/bad-exports.txt"));
        } catch (Exception e) {
            System.out.println("Couldn't Open badExportFile");
            e.printStackTrace();
        }

        
        //Inside Loop
        if (badExportFos != null) {
            try {
                badExportFos.write("contactId, contactListName".getBytes());
                badExportFos.write(System.lineSeparator().getBytes());
            } catch (Exception e) {
                System.out.println("Error writing to badExportFile");
                e.printStackTrace();
            }
        }

        //End of Loop
        try {
            badExportFos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }