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

uk.ac.starlink.util.ByteArrayDataSource Maven / Gradle / Ivy

There is a newer version: 4.3
Show newest version
package uk.ac.starlink.util;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

/**
 * DataSource implementation that uses an internal byte buffer to store
 * the data.
 *
 * @author   Mark Taylor
 * @since    1 Feb 2007
 */
public class ByteArrayDataSource extends DataSource {

    private final String name_;
    private final byte[] buffer_;

    /**
     * Constructor.
     *
     * @param   name  data source name
     * @param   buffer containing byte content of the source
     */
    public ByteArrayDataSource( String name, byte[] buffer ) {
        name_ = name;
        buffer_ = buffer;
    }

    public String getName() {
        return name_;
    }

    public InputStream getRawInputStream() {
        return new ByteArrayInputStream( buffer_ );
    }

    public long getRawLength() {
        return buffer_.length;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy