RandomAccessFile

来源:百度知道 编辑:UC知道 时间:2024/05/26 04:02:28
怎么NEW RandomAccessFile
后面()里面有两个东西。一个是FILE。后面一个是什么

RandomAccessFile(File file, String mode)
Creates a random access file stream to read from, and optionally to write to, the file specified by the File argument.

"r" Open for reading only. Invoking any of the write methods of the resulting object will cause an IOException to be thrown.
"rw" Open for reading and writing. If the file does not already exist then an attempt will be made to create it.
"rws" Open for reading and writing, as with "rw", and also require that every update to the file's content or metadata be written synchronously to the underlying storage device.
"rwd" Open for reading and writing, as with "rw", and also require that every update to the file's content be written synchronously to the underlying storage device.

RandomAccessFile s1=new RandomAccessFile("E:/t.txt","rw");
前者是路径和文件名,后者是对文件具有的权限,比如“rw”是可读可写