Example usage for org.apache.commons.io.output FileWriterWithEncoding flush

List of usage examples for org.apache.commons.io.output FileWriterWithEncoding flush

Introduction

In this page you can find the example usage for org.apache.commons.io.output FileWriterWithEncoding flush.

Prototype

public void flush() throws IOException 

Source Link

Document

Flush the stream.

Usage

From source file:net.ageto.gyrex.impex.common.steps.impl.writers.FileWriter.java

@Override
protected StatusStep process() {

    try {// w  ww.  j  av a2s.  c om
        String filename = (String) getInputParam(FileWriterDefinition.InputParamNames.OUTPUT_FILENAME.name());

        if (StringUtils.isBlank(filename)) {
            processError("{0} missing input.", ID);
            return StatusStep.ERROR;
        }

        StringBuffer content = (StringBuffer) getInputParam(
                FileWriterDefinition.InputParamNames.INPUT_CONTENT.name());

        FileWriterWithEncoding fw = new FileWriterWithEncoding(new File(filename), CharEncoding.UTF_8);
        fw.write(content.toString());
        fw.flush();

    } catch (IOException e) {
        processError("File could not be created.");
    }

    processInfo("{0} has been completed successfully.", ID);

    return StatusStep.OK;
}

From source file:nl.imvertor.common.file.AnyFile.java

public void setContent(String s, boolean append) throws IOException {
    FileWriterWithEncoding out = new FileWriterWithEncoding(this, "UTF-8", append);
    out.write(s);//w ww.jav  a  2 s.c  om
    out.flush();
    out.close();
}

From source file:org.kalypso.model.wspm.tuhh.core.profile.export.knauf.KnaufBeanSerializer.java

@Override
public IStatus execute(final IProgressMonitor monitor) {

    try {//w  w w  .  j  a v a  2s .  c o m
        final FileWriterWithEncoding writer = new FileWriterWithEncoding(m_destination, "Cp1252"); //$NON-NLS-1$

        try {
            for (final AbstractKnaufProjectBean bean : m_beans) {
                final IKnaufPrinter printer = KnaufPrinterFactory.getPrinter(bean);
                writer.append(printer.println());

            }
        } finally {
            writer.flush();
            writer.close();
        }

    } catch (final IOException e) {
        final String msg = Messages.getString("KnaufBeanSerializer_1"); //$NON-NLS-1$

        return new Status(IStatus.ERROR, KalypsoModelWspmCorePlugin.getID(), msg, e);
    }

    return new Status(IStatus.OK, KalypsoModelWspmCorePlugin.getID(),
            Messages.getString("KnaufBeanSerializer_2")); //$NON-NLS-1$
}