base/common/src/main/com/thesett/common/util/FileUtils.java
public static void writeObjectToFile(String outputFileName, Object toWrite, boolean append)
    {
        // Open the output file.
        Writer resultWriter;

        try
        {
            resultWriter = new FileWriter(outputFileName, append);
        }
        catch (IOException e)
        {
            throw new IllegalStateException("Unable to open the output file '" + outputFileName + "' for writing.", e);
        }

        // Write the object into the output file.
        try
        {
            resultWriter.write(toWrite.toString());
            resultWriter.flush();
            resultWriter.close();
        }
        catch (IOException e)
        {
            throw new IllegalStateException("There was an error whilst writing to the output file '" + outputFileName + "'.",
                e);
        }
    }
public static void writeObjectToFile(String outputFileName, Object toWrite, boolean append)
    {
        // Open the output file.
        Writer resultWriter;

        try
        {
            resultWriter = new FileWriter(outputFileName, append);
        }
        catch (IOException e)
        {
            throw new IllegalStateException("Unable to open the output file '" + outputFileName + "' for writing.", e);
        }

        // Write the object into the output file.
        try
        {
            resultWriter.write(toWrite.toString());
            resultWriter.flush();
            resultWriter.close();
        }
        catch (IOException e)
        {
            throw new IllegalStateException("There was an error whilst writing to the output file '" + outputFileName + "'.",
                e);
        }
    }
public static void writeObjectToFile ( String outputFileName , Object toWrite , boolean append ) { // Open the output file. Writer resultWriter ; try { resultWriter = new FileWriter ( outputFileName , append ) ; } catch ( IOException e ) { throw new IllegalStateException ( "Unable to open the output file '" + outputFileName + "' for writing." , e ) ; } // Write the object into the output file. try { resultWriter . write ( toWrite . toString ( ) ) ; resultWriter . flush ( ) ; resultWriter . close ( ) ; } catch ( IOException e ) { throw new IllegalStateException ( "There was an error whilst writing to the output file '" + outputFileName + "'." , e ) ; } }
Writes an object, using its 'toString' method, to the named file. The object may optionally be appended to the
file, or may overwrite it.

@param outputFileName The name of the file to write the output to.
@param toWrite        The object to write to the file.
@param append         <tt>true</tt> to append to the file, <tt>false</tt> to overwrite.
Writes an object using its toString method to the named file . The object may optionally be appended to the file or may overwrite it .