Example usage for org.apache.commons.vfs.util MonitorOutputStream MonitorOutputStream

List of usage examples for org.apache.commons.vfs.util MonitorOutputStream MonitorOutputStream

Introduction

In this page you can find the example usage for org.apache.commons.vfs.util MonitorOutputStream MonitorOutputStream.

Prototype

public MonitorOutputStream(final OutputStream out) 

Source Link

Usage

From source file:com.thinkberg.vfs.s3.jets3t.Jets3tFileObject.java

protected OutputStream doGetOutputStream(boolean bAppend) throws Exception {
    return new MonitorOutputStream(Channels.newOutputStream(getCacheFile().getChannel())) {
        protected void onClose() throws IOException {
            try {
                LOG.debug(String.format("sending '%s' to storage (cached=%b)", object.getKey(), cacheFile));
                if (cacheFile != null) {
                    FileChannel cacheFc = getCacheFile().getChannel();
                    object.setContentLength(cacheFc.size());
                    object.setDataInputStream(Channels.newInputStream(cacheFc));
                }//from   w  w  w .ja  v  a 2 s. c o  m
                service.putObject(bucket, object);
            } catch (S3ServiceException e) {
                LOG.error(String.format("can't send object '%s' to storage", object), e);
            }
        }
    };
}

From source file:org.objectweb.proactive.extensions.vfsprovider.client.ProActiveFileObject.java

@Override
protected OutputStream doGetOutputStream(boolean append) throws Exception {
    return new MonitorOutputStream(new ProActiveOutputStream(append));
}