Class AbstractOrigin.ChannelOrigin
java.lang.Object
org.apache.commons.io.build.AbstractSupplier<Channel, AbstractOrigin.ChannelOrigin>
org.apache.commons.io.build.AbstractOrigin<Channel, AbstractOrigin.ChannelOrigin>
org.apache.commons.io.build.AbstractOrigin.ChannelOrigin
- All Implemented Interfaces:
IOSupplier<Channel>
- Enclosing class:
AbstractOrigin<T, B extends AbstractOrigin<T,B>>
public static class AbstractOrigin.ChannelOrigin
extends AbstractOrigin<Channel, AbstractOrigin.ChannelOrigin>
A
Channel origin.- Since:
- 2.21.0
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractOrigin
AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>, AbstractOrigin.ByteArrayOrigin, AbstractOrigin.ChannelOrigin, AbstractOrigin.CharSequenceOrigin, AbstractOrigin.FileOrigin, AbstractOrigin.InputStreamOrigin, AbstractOrigin.IORandomAccessFileOrigin, AbstractOrigin.OutputStreamOrigin, AbstractOrigin.PathOrigin, AbstractOrigin.RandomAccessFileOrigin, AbstractOrigin.ReaderOrigin, AbstractOrigin.URIOrigin, AbstractOrigin.WriterOrigin -
Constructor Summary
ConstructorsConstructorDescriptionChannelOrigin(Channel origin) Constructs a new instance for the given origin. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Gets this origin as a byte array, if possible.protected ChannelgetChannel(OpenOption... options) Gets this origin as a Channel, if possible.getInputStream(OpenOption... options) Gets this origin as an InputStream, if possible.getOutputStream(OpenOption... options) Gets this origin as an OutputStream, if possible.Gets a new Reader on the origin, buffered by default.getWriter(Charset charset, OpenOption... options) Gets a new Writer on the origin, buffered by default.longsize()Gets the size of the origin, if possible.Methods inherited from class AbstractOrigin
get, getByteArray, getChannel, getCharSequence, getFile, getPath, getRandomAccessFile, toStringMethods inherited from class AbstractSupplier
asThisMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface IOSupplier
asSupplier, getUnchecked
-
Constructor Details
-
ChannelOrigin
Constructs a new instance for the given origin.- Parameters:
origin- The origin, not null.- Throws:
NullPointerException- iforiginisnull.
-
-
Method Details
-
getByteArray
Description copied from class:AbstractOriginGets this origin as a byte array, if possible.- Overrides:
getByteArrayin classAbstractOrigin<Channel, AbstractOrigin.ChannelOrigin>- Returns:
- this origin as a byte array, if possible.
- Throws:
IOException- if an I/O error occurs.
-
getChannel
Gets this origin as a Channel, if possible.No conversion should occur when calling this method.
- Overrides:
getChannelin classAbstractOrigin<Channel, AbstractOrigin.ChannelOrigin>- Parameters:
options- Options specifying how a file-based origin is opened, ignored otherwise.- Returns:
- A new Channel on the origin.
- Throws:
IOException- If an I/O error occurs.- See Also:
-
getInputStream
Description copied from class:AbstractOriginGets this origin as an InputStream, if possible.- Overrides:
getInputStreamin classAbstractOrigin<Channel, AbstractOrigin.ChannelOrigin>- Parameters:
options- options specifying how the file is opened- Returns:
- this origin as an InputStream, if possible.
- Throws:
IOException- if an I/O error occurs.
-
getOutputStream
Description copied from class:AbstractOriginGets this origin as an OutputStream, if possible.- Overrides:
getOutputStreamin classAbstractOrigin<Channel, AbstractOrigin.ChannelOrigin>- Parameters:
options- options specifying how the file is opened- Returns:
- this origin as an OutputStream, if possible.
- Throws:
IOException- if an I/O error occurs.
-
getReader
Description copied from class:AbstractOriginGets a new Reader on the origin, buffered by default.- Overrides:
getReaderin classAbstractOrigin<Channel, AbstractOrigin.ChannelOrigin>- Parameters:
charset- the charset to use for decoding, null maps to the default Charset.- Returns:
- a new Reader on the origin.
- Throws:
IOException- if an I/O error occurs opening the file.
-
getWriter
Description copied from class:AbstractOriginGets a new Writer on the origin, buffered by default.- Overrides:
getWriterin classAbstractOrigin<Channel, AbstractOrigin.ChannelOrigin>- Parameters:
charset- the charset to use for encodingoptions- options specifying how the file is opened- Returns:
- a new Writer on the origin.
- Throws:
IOException- if an I/O error occurs opening or creating the file.
-
size
Description copied from class:AbstractOriginGets the size of the origin, if possible.- Overrides:
sizein classAbstractOrigin<Channel, AbstractOrigin.ChannelOrigin>- Returns:
- the size of the origin in bytes or characters.
- Throws:
IOException- if an I/O error occurs.
-