52 |
{ |
{ |
53 |
private FileDescriptor fd; |
private FileDescriptor fd; |
54 |
|
|
55 |
|
private FileChannel ch; /* cached associated file-channel */ |
56 |
|
|
57 |
/** |
/** |
58 |
* This method initializes a <code>FileOutputStream</code> object to write |
* This method initializes a <code>FileOutputStream</code> object to write |
59 |
* to the named file. The file is created if it does not exist, and |
* to the named file. The file is created if it does not exist, and |
260 |
} |
} |
261 |
|
|
262 |
/** |
/** |
263 |
* This method creates a java.nio.channels.FileChannel. |
* This method creates a java.nio.channels.FileChannel. |
264 |
* Nio does not allow one to create a file channel directly. |
* Nio does not allow one to create a file channel directly. |
265 |
* A file channel must be created by first creating an instance of |
* A file channel must be created by first creating an instance of |
266 |
* Input/Output/RandomAccessFile and invoking the getChannel() method on it. |
* Input/Output/RandomAccessFile and invoking the getChannel() method on it. |
267 |
*/ |
*/ |
268 |
|
public synchronized FileChannel getChannel() |
|
private FileChannel ch; /* cached associated file-channel */ |
|
|
|
|
|
public FileChannel |
|
|
getChannel() |
|
269 |
{ |
{ |
270 |
synchronized (this) |
if (ch == null) |
271 |
{ |
ch = new FileChannelImpl ((int) (fd.getNativeFd() & 0xFFFF), this); |
272 |
// FIXME: Convert NIO to 64 bit |
|
273 |
if (ch == null) |
return ch; |
|
ch = new gnu.java.nio.FileChannelImpl( |
|
|
(int)(fd.getNativeFd() & 0xFFFF), this); |
|
|
} |
|
|
return ch; |
|
274 |
} |
} |
275 |
|
|
276 |
} // class FileOutputStream |
} // class FileOutputStream |