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

net.java.truecommons.io.AbstractSource Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
/*
 * Copyright (C) 2012 Schlichtherle IT Services.
 * All rights reserved. Use is subject to license terms.
 */
package net.java.truecommons.io;

import java.io.IOException;
import java.io.InputStream;
import java.nio.channels.SeekableByteChannel;

/**
 * An abstract provider for input streams or seekable byte channels.
 * 
 * @author Christian Schlichtherle
 */
public abstract class AbstractSource implements Source {

    /**
     * {@inheritDoc}
     * 

* The implementation in the class {@link AbstractSource} calls * {@link #channel()} and wraps the result in a * {@link ChannelInputStream} adapter. * Note that this violates the contract for this method unless you * override either this method or {@link #channel()} with a valid * implementation. */ @Override public InputStream stream() throws IOException { return new ChannelInputStream(channel()); } /** * {@inheritDoc} * * @throws UnsupportedOperationException the implementation in the class * {@link AbstractSource} always throws an exception of * this type. */ @Override public SeekableByteChannel channel() throws IOException { throw new UnsupportedOperationException(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy