Example usage for org.apache.commons.collections ExtendedProperties save

List of usage examples for org.apache.commons.collections ExtendedProperties save

Introduction

In this page you can find the example usage for org.apache.commons.collections ExtendedProperties save.

Prototype

public synchronized void save(OutputStream output, String header) throws IOException 

Source Link

Document

Save the properties to the given output stream.

Usage

From source file:autohit.server.command.CommandSaveProps.java

/**
 * Execute the command./* w  w w .  j  a va 2  s .c  om*/
 * 
 * @throws ServerException
 * @return return the manreadable message for success.
 */
public String execute() throws ServerException {

    String victory = "failed.";
    boolean started = false;

    // Trap all non-critical errors and just log them to the
    // responseChannel
    try {

        // Get the properties and try to save them.
        ExtendedProperties iprops = sc.getInvokerProperties();
        OutputStream is = uni.putStream(command);
        iprops.save(is, "INVOKER PROPERIES " + System.currentTimeMillis());
        is.close();

        // Ok, it's working
        victory = "saved.";

    } catch (IOException ioe) {
        throw new ServerException("failed.  There was an IO error.  message=" + ioe.getMessage(),
                AutohitErrorCodes.EVENT_COMMAND_FAILED, ioe);

    } catch (UniverseException ue) {

        throw new ServerException("failed.  There was a Universe Exception.  message=" + ue.getMessage(),
                AutohitErrorCodes.EVENT_COMMAND_FAILED, ue);

    } catch (Exception e) {

        throw new ServerException("failed.  There was a general Exception.  message=" + e.getMessage(),
                AutohitErrorCodes.EVENT_COMMAND_FAILED, e);
    }

    // return
    return victory;
}

From source file:com.liferay.portal.velocity.FastExtendedProperties.java

public FastExtendedProperties(ExtendedProperties extendedProperties) throws IOException {

    UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();

    extendedProperties.save(unsyncByteArrayOutputStream, StringPool.BLANK);

    InputStream inputStream = new UnsyncByteArrayInputStream(unsyncByteArrayOutputStream.unsafeGetByteArray(),
            0, unsyncByteArrayOutputStream.size());

    load(inputStream);// w  w  w. jav  a2  s  . c  o  m
}