Randomaccessfile
Randomaccessfile is a class that randomly accesses files (including read/write). It supports read and write random access to files, that is, we can read/write file data from a specified location.
It should be noted that although Randomaccessfile belongs to the java.io package, it is not a inputstream or outputstream subclass; it is also different from FileInputStream and FileOutputStream. FileInputStream can only read files and FileOutputStream write to files, but Randomaccessfile also supports read and write files, and it supports random access.
Randomaccessfile Function List
Randomaccessfile (file file, string mode) Randomaccessfile (string fileName, string mode) void Close () Synchroniz Ed final FileChannel Getchannel () Final FileDescriptor getfd () long getfilepointer () long length () int Read (byte[] buffer, int byteoffset, int byteCount) int read (byte[) buffer int Read () Final Boolean readboole An () Final byte readbyte () final char Readchar () final double readdouble () final float readfloat () Final V OID readfully (byte[] DST) final void readfully (byte[] DST, int offset, int byteCount) final int readInt () Fina L String ReadLine () Final long Readlong () final short readshort () Final String readUTF () final int rea Dunsignedbyte () Final int readunsignedshort () void seek (long offset) void SetLength (long newlength) int SK ipbytes (int count) void write (int onebyte) void write (byte[] buffer, int byteoffset, int byteCount) void write (byte[] buffer) Final VOID Writeboolean (boolean val) final void WriteByte (int val) final void writebytes (String str) final void WR Itechar (int val) final void WriteChars (String str) final void writedouble (double val) final void Writefloat (fl Oat val) final void Writeint (int val) final void Writelong (long val) final void Writeshort (int val) final void writeUTF (String str)
1. Randomaccessfile Mode description
There are 4 modes of randomaccessfile: "R", "RW", "RWS" and "RWD".
"R" opens in read-only mode. Any write method that invokes the result object will cause the IOException to be thrown.
"RW" opens for reading and writing.
"RWS" opens for reading and writing. Relative to RW, RWS also requires that each update to the contents of the file or metadata be written to the underlying storage device synchronously.
"RWD" is opened for reading and writing, and "RWD" also requires that every update to the contents of the file be written to the underlying storage device synchronously, as opposed to "RW".
Description
(01) What is "meta data", that is, metadata?
The English explanation is as follows:
The definition of metadata is ' data about other data. ' With a file system, the data are contained in its files and directories, and the metadata tracks information about each of These objects:is it a regular file, directory A, or a link? What is it size, creation date, last modified date, file owner, group owner, and access permissions?
The General meaning is:
Metadata is "data about data." In a file system, data is contained in files and folders; Metadata information includes: "Data is a file, a directory or a link", "Data creation time (referred to as CTime)", "Last Modification Time (mtime)", "Data owner", "Data ownership group" , "access rights", and so on.