All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.directwebremoting.extend.InputStreamFactoryOutputStreamLoader Maven / Gradle / Ivy

Go to download

DWR is easy Ajax for Java. It makes it simple to call Java code directly from Javascript. It gets rid of almost all the boilerplate code between the web browser and your Java code. This version 4.0.2 works with Jakarta Servlet 4.0.2.

The newest version!
package org.directwebremoting.extend;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.directwebremoting.io.FileTransfer;
import org.directwebremoting.io.InputStreamFactory;
import org.directwebremoting.io.OutputStreamLoader;
import org.directwebremoting.util.CopyUtils;

/**
 * Used when the {@link FileTransfer} has a {@link InputStreamFactory}, but what
 * it really wants is an {@link OutputStreamLoader}
 * @author Joe Walker [joe at getahead dot ltd dot uk]
 */
public final class InputStreamFactoryOutputStreamLoader implements OutputStreamLoader
{
    public InputStreamFactoryOutputStreamLoader(InputStreamFactory inputStreamFactory)
    {
        this.inputStreamFactory = inputStreamFactory;
    }

    public void load(OutputStream out) throws IOException
    {
        InputStream in = inputStreamFactory.getInputStream();
        CopyUtils.copy(in, out);
    }

    public void close() throws IOException
    {
        inputStreamFactory.close();
    }

    /**
     * The object we are proxying to
     */
    private final InputStreamFactory inputStreamFactory;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy