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

org.codehaus.stax2.io.Stax2FileResult Maven / Gradle / Ivy

Go to download

Stax2 API is an extension to basic Stax 1.0 API that adds significant new functionality, such as full-featured bi-direction validation interface and high-performance Typed Access API.

There is a newer version: 4.2.2
Show newest version
package org.codehaus.stax2.io;

import java.io.*;

/**
 * Simple implementation of {@link Stax2ReferentialResult}, which refers
 * to the specific file.
 */
public class Stax2FileResult
    extends Stax2ReferentialResult
{
    final File mFile;

    public Stax2FileResult(File f) {
        mFile = f;
    }

    /*
    /////////////////////////////////////////
    // Implementation of the Public API
    /////////////////////////////////////////
     */

    @Override
    public Writer constructWriter() throws IOException
    {
        String enc = getEncoding();
        if (enc != null && enc.length() > 0) {
            return new OutputStreamWriter(constructOutputStream(), enc);
        }
        // Sub-optimal; really shouldn't use the platform default encoding
        return new FileWriter(mFile);
    }

    @Override
    public OutputStream constructOutputStream() throws IOException
    {
        return new FileOutputStream(mFile);
    }

    /*
    /////////////////////////////////////////
    // Additional API for this Result
    /////////////////////////////////////////
     */

    public File getFile() {
        return mFile;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy