public static void write(String fileName, Collection<? extends Object> entries) {
        if (fileName == null) {
            throw new IllegalArgumentException("Must specify a file name to write to");
        }
        PrintWriter writer = null;
        File file = new File(fileName);
        try {
            file.mkdirs();
            if (file.exists()) {
                file.delete();
            }
            writer = new PrintWriter(new FileWriter(file), true);
            for (Object entry : entries) {
                writer.println(String.valueOf(entry));
            }
        }
        catch (Exception e) {
            throw new RuntimeException("Problem writing to " + file.getAbsolutePath(), e);
        }
        finally {
            try {
            	if(writer != null) {
            		writer.close();
                }
            }
            catch (Exception e) {
                //
            }
        }
    }
public static void write ( String fileName , Collection < ? extends Object > entries ) { if ( fileName == null ) { throw new IllegalArgumentException ( "Must specify a file name to write to" ) ; } PrintWriter writer = null ; File file = new File ( fileName ) ; try { file . mkdirs ( ) ; if ( file . exists ( ) ) { file . delete ( ) ; } writer = new PrintWriter ( new FileWriter ( file ) , true ) ; for ( Object entry : entries ) { writer . println ( String . valueOf ( entry ) ) ; } } catch ( Exception e ) { throw new RuntimeException ( "Problem writing to " + file . getAbsolutePath ( ) , e ) ; } finally { try { if ( writer != null ) { writer . close ( ) ; } } catch ( Exception e ) { } } }
Constructor.
@param fileName the name of the file to write to
@param entries the strings to write to the file (one string per line)
@throws IllegalArgumentException if enabled but no file name defined