Package org.apache.commons.io.build
Class AbstractOrigin.AbstractRandomAccessFileOrigin<T extends java.io.RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>>
- java.lang.Object
-
- org.apache.commons.io.build.AbstractSupplier<T,B>
-
- org.apache.commons.io.build.AbstractOrigin<T,B>
-
- org.apache.commons.io.build.AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>
-
- Type Parameters:
T- the type of instances to build.B- the type of builder subclass.
- All Implemented Interfaces:
IOSupplier<T>
- Direct Known Subclasses:
AbstractOrigin.IORandomAccessFileOrigin,AbstractOrigin.RandomAccessFileOrigin
- Enclosing class:
- AbstractOrigin<T,B extends AbstractOrigin<T,B>>
public abstract static class AbstractOrigin.AbstractRandomAccessFileOrigin<T extends java.io.RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>> extends AbstractOrigin<T,B>
ARandomAccessFileorigin.This origin cannot support File and Path since you cannot query a RandomAccessFile for those attributes; Use
AbstractOrigin.IORandomAccessFileOrigininstead.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.io.build.AbstractOrigin
AbstractOrigin.AbstractRandomAccessFileOrigin<T extends java.io.RandomAccessFile,B extends 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
Constructors Constructor Description AbstractRandomAccessFileOrigin(T origin)ARandomAccessFileorigin.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getByteArray()Gets this origin as a byte array, if possible.byte[]getByteArray(long position, int length)Gets a portion of this origin as a byte array, if possible.protected java.nio.channels.ChannelgetChannel(java.nio.file.OpenOption... options)Gets this origin as a Channel, if possible.java.lang.CharSequencegetCharSequence(java.nio.charset.Charset charset)Gets this origin as a byte array, if possible.java.io.InputStreamgetInputStream(java.nio.file.OpenOption... options)Gets this origin as an InputStream, if possible.java.io.OutputStreamgetOutputStream(java.nio.file.OpenOption... options)Gets this origin as an OutputStream, if possible.TgetRandomAccessFile(java.nio.file.OpenOption... openOption)Gets this origin as a RandomAccessFile, if possible.java.io.ReadergetReader(java.nio.charset.Charset charset)Gets a new Reader on the origin, buffered by default.java.io.WritergetWriter(java.nio.charset.Charset charset, java.nio.file.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 org.apache.commons.io.build.AbstractOrigin
get, getChannel, getFile, getPath, toString
-
Methods inherited from class org.apache.commons.io.build.AbstractSupplier
asThis
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.io.function.IOSupplier
asSupplier, getUnchecked
-
-
-
-
Constructor Detail
-
AbstractRandomAccessFileOrigin
public AbstractRandomAccessFileOrigin(T origin)
ARandomAccessFileorigin.Starting from this origin, you can everything except a Path and a File.
- Parameters:
origin- The origin, not null.- Throws:
java.lang.NullPointerException- iforiginisnull.
-
-
Method Detail
-
getByteArray
public byte[] getByteArray() throws java.io.IOException
Description copied from class:AbstractOriginGets this origin as a byte array, if possible.- Overrides:
getByteArrayin classAbstractOrigin<T extends java.io.RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>>- Returns:
- this origin as a byte array, if possible.
- Throws:
java.io.IOException- if an I/O error occurs.
-
getByteArray
public byte[] getByteArray(long position, int length) throws java.io.IOException
Description copied from class:AbstractOriginGets a portion of this origin as a byte array, if possible.- Overrides:
getByteArrayin classAbstractOrigin<T extends java.io.RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>>- Parameters:
position- the initial index of the range to be copied, inclusive.length- How many bytes to copy.- Returns:
- this origin as a byte array, if possible.
- Throws:
java.io.IOException- if an I/O error occurs.
-
getChannel
protected java.nio.channels.Channel getChannel(java.nio.file.OpenOption... options) throws java.io.IOException
Description copied from class:AbstractOriginGets this origin as a Channel, if possible.- Overrides:
getChannelin classAbstractOrigin<T extends java.io.RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>>- Parameters:
options- Options specifying how a file-based origin is opened, ignored otherwise.- Returns:
- A new Channel on the origin.
- Throws:
java.io.IOException- If an I/O error occurs.- See Also:
AbstractOrigin.getChannel(Class, OpenOption...)
-
getCharSequence
public java.lang.CharSequence getCharSequence(java.nio.charset.Charset charset) throws java.io.IOException
Description copied from class:AbstractOriginGets this origin as a byte array, if possible.- Overrides:
getCharSequencein classAbstractOrigin<T extends java.io.RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>>- Parameters:
charset- The charset to use if conversion from bytes is needed.- Returns:
- this origin as a byte array, if possible.
- Throws:
java.io.IOException- if an I/O error occurs.
-
getInputStream
public java.io.InputStream getInputStream(java.nio.file.OpenOption... options) throws java.io.IOException
Description copied from class:AbstractOriginGets this origin as an InputStream, if possible.- Overrides:
getInputStreamin classAbstractOrigin<T extends java.io.RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>>- Parameters:
options- options specifying how the file is opened- Returns:
- this origin as an InputStream, if possible.
- Throws:
java.io.IOException- if an I/O error occurs.
-
getOutputStream
public java.io.OutputStream getOutputStream(java.nio.file.OpenOption... options) throws java.io.IOException
Description copied from class:AbstractOriginGets this origin as an OutputStream, if possible.- Overrides:
getOutputStreamin classAbstractOrigin<T extends java.io.RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>>- Parameters:
options- options specifying how the file is opened- Returns:
- this origin as an OutputStream, if possible.
- Throws:
java.io.IOException- if an I/O error occurs.
-
getRandomAccessFile
public T getRandomAccessFile(java.nio.file.OpenOption... openOption)
Description copied from class:AbstractOriginGets this origin as a RandomAccessFile, if possible.- Overrides:
getRandomAccessFilein classAbstractOrigin<T extends java.io.RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>>- Parameters:
openOption- options likeStandardOpenOption.- Returns:
- this origin as a RandomAccessFile, if possible.
-
getReader
public java.io.Reader getReader(java.nio.charset.Charset charset) throws java.io.IOException
Description copied from class:AbstractOriginGets a new Reader on the origin, buffered by default.- Overrides:
getReaderin classAbstractOrigin<T extends java.io.RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>>- Parameters:
charset- the charset to use for decoding, null maps to the default Charset.- Returns:
- a new Reader on the origin.
- Throws:
java.io.IOException- if an I/O error occurs opening the file.
-
getWriter
public java.io.Writer getWriter(java.nio.charset.Charset charset, java.nio.file.OpenOption... options) throws java.io.IOException
Description copied from class:AbstractOriginGets a new Writer on the origin, buffered by default.- Overrides:
getWriterin classAbstractOrigin<T extends java.io.RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>>- Parameters:
charset- the charset to use for encodingoptions- options specifying how the file is opened- Returns:
- a new Writer on the origin.
- Throws:
java.io.IOException- if an I/O error occurs opening or creating the file.
-
size
public long size() throws java.io.IOException
Description copied from class:AbstractOriginGets the size of the origin, if possible.- Overrides:
sizein classAbstractOrigin<T extends java.io.RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>>- Returns:
- the size of the origin in bytes or characters.
- Throws:
java.io.IOException- if an I/O error occurs.
-
-