public class NStream extends NObject implements ByteChannel
NObject.FromHandle, NObject.NObjectCallback, NObject.NObjectPropertyChangedCallbackchangedCallback, changingCallback, FLAG_REF_RET, propertyChangedCallback, stateChangedCallback| Modifier | Constructor and Description |
|---|---|
protected |
NStream(HNObject handle,
boolean claimHandle) |
| Modifier and Type | Method and Description |
|---|---|
InputStream |
asInputStream()
Converts the current stream into input stream.
|
OutputStream |
asOutputStream()
Converts the current stream into output stream.
|
boolean |
canRead()
Checks whether the current stream can read.
|
boolean |
canSeek()
Checks whether the current stream can seek.
|
boolean |
canWrite()
Checks whether the current stream can write.
|
protected void |
checkCanRead() |
protected void |
checkCanReadUnchecked() |
protected void |
checkCanWrite() |
protected void |
checkCanWriteUnchecked() |
protected void |
checkIsOpen() |
void |
close()
Closes the current stream.
|
void |
copyFrom(NStream stream,
int bufferSize) |
void |
copyTo(NStream stream) |
void |
force(boolean metaData)
Forces any updates to this channel's file to be written to the storage device that contains it.
|
static NStream |
fromChannel(ByteChannel ch)
Creates a new stream from specified byte channel.
|
static NStream |
fromChannel(FileChannel ch)
Creates a new stream from specified file channel.
|
static NStream |
fromChannel(FileChannel ch,
NFileAccess fa)
Creates a new stream from specified file channel.
|
static NStream |
fromChannel(ReadableByteChannel ch)
Creates a new stream from specified readable byte channel.
|
static NStream |
fromChannel(WritableByteChannel ch)
Creates a new stream from specified writable byte channel.
|
static NStream |
fromInputStream(FileInputStream in)
Creates a new stream from specified file input stream.
|
static NStream |
fromInputStream(InputStream in)
Creates a new stream from specified input stream.
|
static NStream |
fromOutputStream(FileOutputStream out)
Creates a new stream from specified file output stream.
|
static NStream |
fromOutputStream(OutputStream out)
Creates a new stream from specified output stream.
|
static NStream |
fromRandomAccessFile(RandomAccessFile raf)
Creates a new stream from specified random access file.
|
static NStream |
fromRandomAccessFile(RandomAccessFile raf,
NFileAccess fa)
Creates a new stream from specified random access file with specified file access.
|
static NStream |
getNull()
Returns NStream with no backing store.
|
static NStream |
getSynchronized(NStream stream)
Gets a synchronized version of the specified stream.
|
boolean |
isOpen()
Checks whether the stream is open.
|
static NType |
nativeTypeOf()
Retrieves the native type for the enclosing class.
|
long |
position()
Gets the position of the current stream.
|
NStream |
position(long newPosition)
Sets the position of the current stream.
|
int |
read(ByteBuffer dst)
Reads the bytes from the current stream and writes them to the specified byte buffer.
|
int |
read(NBuffer dst) |
long |
size()
Gets the size of the current stream.
|
NStream |
truncate(long size)
Reduces current stream's size to the specified value.
|
int |
write(ByteBuffer src)
Reads the bytes from the specified byte buffer and writes them to the current stream.
|
int |
write(NBuffer src) |
addListener, addPropertyChangeListener, captureProperties, claimHandle, clone, compareTo, copyProperties, dispose, disposeArray, equals, fromHandle, fromHandle, fromObject, getFlags, getHandle, getNativeType, getOwner, getProperty, getProperty, getSize, getSize, getSizeMany, getSizeMany, hashCode, invoke, invoke, invoke, isDisposed, nObjectCallbackNativeTypeOf, nObjectPropertyChangedCallbackNativeTypeOf, ref, removeListener, removePropertyChangeListener, reset, resetProperty, save, save, save, save, save, save, save, save, save, save, save, save, saveMany, saveMany, saveMany, saveMany, saveMany, saveMany, saveMany, saveMany, saveMany, saveMany, saveMany, saveMany, setFlags, setProperty, setProperty, toHandle, toObject, toString, toString, unref, unrefArray, unrefElementscheck, dispose, finalizeprotected NStream(HNObject handle, boolean claimHandle)
public static NType nativeTypeOf()
public static NStream fromInputStream(InputStream in)
in - The source input stream.public static NStream fromOutputStream(OutputStream out)
out - The source output stream.public static NStream fromInputStream(FileInputStream in)
in - The source file input stream.public static NStream fromOutputStream(FileOutputStream out)
out - The source file output stream.public static NStream fromRandomAccessFile(RandomAccessFile raf)
raf - The source random access file.public static NStream fromRandomAccessFile(RandomAccessFile raf, NFileAccess fa)
raf - The source random access file.fa - File access value.public static NStream fromChannel(ReadableByteChannel ch)
ch - The source readable byte channel.public static NStream fromChannel(WritableByteChannel ch)
ch - The source writable byte channel.public static NStream fromChannel(ByteChannel ch)
ch - The source byte channel.public static NStream fromChannel(FileChannel ch)
ch - The source file channel.public static NStream fromChannel(FileChannel ch, NFileAccess fa)
ch - The source file channel.fa - File access value.public static NStream getSynchronized(NStream stream)
stream - Source NStream.public static NStream getNull()
protected final void checkIsOpen()
throws ClosedChannelException
ClosedChannelExceptionprotected final void checkCanRead()
throws ClosedChannelException
ClosedChannelExceptionprotected final void checkCanWrite()
throws ClosedChannelException
ClosedChannelExceptionprotected final void checkCanReadUnchecked()
protected final void checkCanWriteUnchecked()
public final InputStream asInputStream()
public final OutputStream asOutputStream()
public final void copyTo(NStream stream) throws IOException
IOExceptionpublic final void copyFrom(NStream stream, int bufferSize) throws IOException
IOExceptionpublic final boolean canRead()
public final boolean canWrite()
public final boolean canSeek()
public final void force(boolean metaData)
throws IOException
metaData - If true then this method is required to force changes to both the file's content and metadata to be written to storage; otherwise, it need only force content changes to be writtenIOExceptionpublic final long size()
throws IOException
IOExceptionpublic final NStream truncate(long size) throws IOException
size - New stream size.IOExceptionpublic final long position()
throws IOException
IOExceptionpublic final NStream position(long newPosition) throws IOException
newPosition - New position of NStream.IOExceptionpublic final boolean isOpen()
public final void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface ChannelIOExceptionpublic final int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChanneldst - The destination byte buffer.IOExceptionpublic final int read(NBuffer dst) throws IOException
IOExceptionpublic final int write(ByteBuffer src) throws IOException
write in interface WritableByteChannelsrc - The source byte buffer.IOExceptionpublic final int write(NBuffer src) throws IOException
IOExceptionCopyright © 2016 Neurotechnology. All rights reserved.