39 |
package java.io; |
package java.io; |
40 |
|
|
41 |
import gnu.classpath.Configuration; |
import gnu.classpath.Configuration; |
42 |
|
import java.nio.channels.FileChannel; |
43 |
|
import gnu.java.nio.FileChannelImpl; |
44 |
|
|
45 |
/** |
/** |
46 |
* This class allows reading and writing of files at random locations. |
* This class allows reading and writing of files at random locations. |
1225 |
write(buf); |
write(buf); |
1226 |
} |
} |
1227 |
|
|
1228 |
|
/*************************************************************************/ |
1229 |
|
|
1230 |
|
/** |
1231 |
|
* This method creates a java.nio.channels.FileChannel. |
1232 |
|
* Nio does not allow one to create a file channel directly. |
1233 |
|
* A file channel must be created by first creating an instance of |
1234 |
|
* Input/Output/RandomAccessFile and invoking the getChannel() method on it. |
1235 |
|
*/ |
1236 |
|
|
1237 |
|
private FileChannel ch; /* cached associated file-channel */ |
1238 |
|
|
1239 |
|
public FileChannel |
1240 |
|
getChannel() |
1241 |
|
{ |
1242 |
|
synchronized (this) |
1243 |
|
{ |
1244 |
|
if (ch == null) |
1245 |
|
ch = new gnu.java.nio.FileChannelImpl(native_fd, |
1246 |
|
this); |
1247 |
|
} |
1248 |
|
return ch; |
1249 |
|
} |
1250 |
|
|
1251 |
|
|
1252 |
} // class RandomAccessFile |
} // class RandomAccessFile |
1253 |
|
|