|
|||||||||
| Home >> All >> gnu >> java >> nio >> [ channels overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
gnu.java.nio.channels
Class FileChannelImpl

java.lang.Objectjava.nio.channels.spi.AbstractInterruptibleChannel
java.nio.channels.FileChannel
gnu.java.nio.channels.FileChannelImpl
- All Implemented Interfaces:
- java.nio.channels.ByteChannel, java.nio.channels.Channel, java.nio.channels.GatheringByteChannel, java.nio.channels.InterruptibleChannel, java.nio.channels.ReadableByteChannel, java.nio.channels.ScatteringByteChannel, java.nio.channels.WritableByteChannel
- public final class FileChannelImpl
- extends java.nio.channels.FileChannel
This file is not user visible ! But alas, Java does not have a concept of friendly packages so this class is public. Instances of this class are created by invoking getChannel Upon a Input/Output/RandomAccessFile object.
| Nested Class Summary |
| Nested classes inherited from class java.nio.channels.FileChannel |
java.nio.channels.FileChannel.MapMode |
| Field Summary | |
static int |
APPEND
|
(package private) java.lang.String |
description
|
static int |
DSYNC
|
static FileChannelImpl |
err
|
static int |
EXCL
|
private int |
fd
This is the actual native file descriptor value |
static FileChannelImpl |
in
|
private int |
mode
|
static FileChannelImpl |
out
|
static int |
READ
|
static int |
SYNC
|
static int |
WRITE
|
| Fields inherited from class java.nio.channels.spi.AbstractInterruptibleChannel |
|
| Constructor Summary | |
private |
FileChannelImpl(java.io.File file,
int mode)
|
(package private) |
FileChannelImpl(int fd,
int mode)
Constructor for default channels in, out and err. |
| Method Summary | |
int |
available()
|
static FileChannelImpl |
create(java.io.File file,
int mode)
|
protected void |
finalize()
Makes sure the Channel is properly closed. |
private void |
force()
|
void |
force(boolean metaData)
msync with the disk |
protected void |
implCloseChannel()
Closes the channel. |
private long |
implPosition()
|
private void |
implTruncate(long size)
|
private static void |
init()
|
java.nio.channels.FileLock |
lock(long position,
long size,
boolean shared)
Creates a file lock for a region of the associated file. |
private boolean |
lock(long position,
long size,
boolean shared,
boolean wait)
Try to acquire a lock at the given position and size. |
private void |
lockCheck(long position,
long size,
boolean shared)
|
java.nio.MappedByteBuffer |
map(java.nio.channels.FileChannel.MapMode mode,
long position,
long size)
Maps the file into the memory. |
java.nio.MappedByteBuffer |
mapImpl(char mode,
long position,
int size)
|
private int |
open(java.lang.String path,
int mode)
|
long |
position()
Returns the current position on the file. |
java.nio.channels.FileChannel |
position(long newPosition)
Sets the position of the channel on the assoziated file. |
int |
read()
|
int |
read(byte[] buffer,
int offset,
int length)
|
int |
read(java.nio.ByteBuffer dst)
Reads data from the channel. |
long |
read(java.nio.ByteBuffer[] dsts,
int offset,
int length)
Reads data from the channel. |
int |
read(java.nio.ByteBuffer dst,
long position)
Reads data from the channel. |
private void |
seek(long newPosition)
|
long |
size()
Return the size of the file thus far |
private int |
smallTransferFrom(java.nio.channels.ReadableByteChannel src,
long position,
int count)
|
private int |
smallTransferTo(long position,
int count,
java.nio.channels.WritableByteChannel target)
|
java.lang.String |
toString()
Convert this Object to a human-readable String. |
long |
transferFrom(java.nio.channels.ReadableByteChannel src,
long position,
long count)
Transfers bytes from the given readable channel into this channel. |
long |
transferTo(long position,
long count,
java.nio.channels.WritableByteChannel target)
Transfers bytes from this channel's file to the given writable byte channel. |
java.nio.channels.FileChannel |
truncate(long size)
Truncates the channel's file at size. |
java.nio.channels.FileLock |
tryLock(long position,
long size,
boolean shared)
Tries to aqquire a lock on a region of the associated file. |
void |
unlock(long pos,
long len)
|
void |
write(byte[] buffer,
int offset,
int length)
|
int |
write(java.nio.ByteBuffer src)
Writes data to the channel. |
long |
write(java.nio.ByteBuffer[] srcs,
int offset,
int length)
Writes data to the channel. |
int |
write(java.nio.ByteBuffer src,
long position)
Writes data to the channel. |
void |
write(int b)
|
| Methods inherited from class java.nio.channels.FileChannel |
lock, read, tryLock, write |
| Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel |
begin, close, end, isOpen |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.nio.channels.Channel |
close, isOpen |
| Field Detail |
READ
public static final int READ
- See Also:
- Constant Field Values
WRITE
public static final int WRITE
- See Also:
- Constant Field Values
APPEND
public static final int APPEND
- See Also:
- Constant Field Values
EXCL
public static final int EXCL
- See Also:
- Constant Field Values
SYNC
public static final int SYNC
- See Also:
- Constant Field Values
DSYNC
public static final int DSYNC
- See Also:
- Constant Field Values
in
public static FileChannelImpl in
out
public static FileChannelImpl out
err
public static FileChannelImpl err
fd
private int fd
- This is the actual native file descriptor value
mode
private int mode
description
final java.lang.String description
| Constructor Detail |
FileChannelImpl
private FileChannelImpl(java.io.File file, int mode) throws java.io.FileNotFoundException
FileChannelImpl
FileChannelImpl(int fd,
int mode)
- Constructor for default channels in, out and err.
Used by init() (native code).
| Method Detail |
init
private static void init()
create
public static FileChannelImpl create(java.io.File file, int mode) throws java.io.FileNotFoundException
open
private int open(java.lang.String path, int mode) throws java.io.FileNotFoundException
available
public int available()
throws java.io.IOException
implPosition
private long implPosition()
throws java.io.IOException
seek
private void seek(long newPosition)
throws java.io.IOException
implTruncate
private void implTruncate(long size)
throws java.io.IOException
unlock
public void unlock(long pos,
long len)
throws java.io.IOException
size
public long size()
throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Return the size of the file thus far
implCloseChannel
protected void implCloseChannel()
throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Closes the channel.
This is called from @see close.
finalize
protected void finalize()
throws java.io.IOException
- Makes sure the Channel is properly closed.
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Reads data from the channel.
read
public int read(java.nio.ByteBuffer dst, long position) throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Reads data from the channel.
read
public int read()
throws java.io.IOException
read
public int read(byte[] buffer,
int offset,
int length)
throws java.io.IOException
read
public long read(java.nio.ByteBuffer[] dsts, int offset, int length) throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Reads data from the channel.
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Writes data to the channel.
write
public int write(java.nio.ByteBuffer src, long position) throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Writes data to the channel.
write
public void write(byte[] buffer,
int offset,
int length)
throws java.io.IOException
write
public void write(int b)
throws java.io.IOException
write
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Writes data to the channel.
mapImpl
public java.nio.MappedByteBuffer mapImpl(char mode, long position, int size) throws java.io.IOException
map
public java.nio.MappedByteBuffer map(java.nio.channels.FileChannel.MapMode mode, long position, long size) throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Maps the file into the memory.
force
public void force(boolean metaData)
throws java.io.IOException
- msync with the disk
force
private void force()
smallTransferTo
private int smallTransferTo(long position,
int count,
java.nio.channels.WritableByteChannel target)
throws java.io.IOException
transferTo
public long transferTo(long position,
long count,
java.nio.channels.WritableByteChannel target)
throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Transfers bytes from this channel's file to the given writable byte
channel.
smallTransferFrom
private int smallTransferFrom(java.nio.channels.ReadableByteChannel src, long position, int count) throws java.io.IOException
transferFrom
public long transferFrom(java.nio.channels.ReadableByteChannel src, long position, long count) throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Transfers bytes from the given readable channel into this channel.
lockCheck
private void lockCheck(long position,
long size,
boolean shared)
throws java.io.IOException
tryLock
public java.nio.channels.FileLock tryLock(long position, long size, boolean shared) throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Tries to aqquire a lock on a region of the associated file.
lock
private boolean lock(long position,
long size,
boolean shared,
boolean wait)
throws java.io.IOException
- Try to acquire a lock at the given position and size.
On success return true.
If wait as specified, block until we can get it.
Otherwise return false.
lock
public java.nio.channels.FileLock lock(long position, long size, boolean shared) throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Creates a file lock for a region of the associated file.
position
public long position()
throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Returns the current position on the file.
position
public java.nio.channels.FileChannel position(long newPosition) throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Sets the position of the channel on the assoziated file.
truncate
public java.nio.channels.FileChannel truncate(long size) throws java.io.IOException
- Description copied from class:
java.nio.channels.FileChannel - Truncates the channel's file at
size.
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
|
|||||||||
| Home >> All >> gnu >> java >> nio >> [ channels overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC