Package com.jogamp.common.nio
Class MappedByteBufferOutputStream
java.lang.Object
java.io.OutputStream
com.jogamp.common.nio.MappedByteBufferOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
An
OutputStream implementation based on an underlying FileChannel's memory mapped ByteBuffer.
Implementation is based on MappedByteBufferInputStream, using it as its parent instance.
An instance maybe created via its parent MappedByteBufferInputStream.getOutputStream(FileResizeOp)
or directly MappedByteBufferOutputStream(FileChannel, MapMode, CacheMode, int, FileResizeOp).
- Since:
- 2.3.0
-
Constructor Summary
ConstructorsConstructorDescriptionMappedByteBufferOutputStream(FileChannel fileChannel, FileChannel.MapMode mmode, MappedByteBufferInputStream.CacheMode cmode, int sliceShift, MappedByteBufferInputStream.FileResizeOp fileResizeOp) Creates a new instance using the givenFileChannel. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()final voidflush()final voidflush(boolean metaData) final booleanfinal longlength()final voidnotifyLengthChange(long newTotalSize) final longposition()position(long newPosition) final longfinal voidsetLength(long newTotalSize) final voidsetSynchronous(boolean s) final longskip(long n) final voidwrite(byte[] b, int off, int len) final voidwrite(int b) final voidwrite(MappedByteBufferInputStream b, long len) Perform similar towrite(ByteBuffer, int)withMappedByteBufferInputStreaminstead of byte array.final voidwrite(ByteBuffer b, int len) Perform similar towrite(byte[], int, int)withByteBufferinstead of byte array.Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
MappedByteBufferOutputStream
public MappedByteBufferOutputStream(FileChannel fileChannel, FileChannel.MapMode mmode, MappedByteBufferInputStream.CacheMode cmode, int sliceShift, MappedByteBufferInputStream.FileResizeOp fileResizeOp) throws IOException Creates a new instance using the givenFileChannel.The
ByteBufferslices will be mapped lazily at first usage.- Parameters:
fileChannel- the file channel to be mapped lazily.mmode- the map mode, default isFileChannel.MapMode.READ_WRITE.cmode- the caching mode, default isMappedByteBufferInputStream.CacheMode.FLUSH_PRE_SOFT.sliceShift- the pow2 slice size, default isMappedByteBufferInputStream.DEFAULT_SLICE_SHIFT.fileResizeOp-MappedByteBufferInputStream.FileResizeOpas described onMappedByteBufferInputStream.setFileResizeOp(FileResizeOp).- Throws:
IOException
-
-
Method Details
-
setSynchronous
public final void setSynchronous(boolean s) -
getSynchronous
public final boolean getSynchronous() -
setLength
- Throws:
IOException
-
notifyLengthChange
- Throws:
IOException
-
length
public final long length() -
remaining
- Throws:
IOException
-
position
- Throws:
IOException
-
position
- Throws:
IOException
-
skip
- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
flush
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
Perform similar towrite(byte[], int, int)withByteBufferinstead of byte array.- Parameters:
b- theByteBuffersource, data is read from currentBuffer.position()len- the number of bytes to write- Throws:
IOException- if a buffer slice operation failed or stream has beenclosed.
-
write
Perform similar towrite(ByteBuffer, int)withMappedByteBufferInputStreaminstead of byte array.Method directly copies memory mapped
ByteBuffer'ed data from the given input stream to this stream without extra data copy.- Parameters:
b- theByteBuffersource, data is read from currentMappedByteBufferInputStream.position()len- the number of bytes to write- Throws:
IOException- if a buffer slice operation failed or stream has beenclosed.
-