Mark and reset operations for Java InputStream
Mark is used to mark the current position; FileInputStream does not support mark and reeset two functions;
But Bufferedinputstream supports this operation;
After the mark (READLIMIT) tag, subsequent calls to the Reset () function will bring the file stream back to mark's position for reuse.
If it's not mark, then you can't read it again after reading the end of the file.
Mark and reset should be used in conjunction.
FileInputStream infile = new FileInputStream ("test.txt");
Buffedfile = new Bufferedinputstream (infile);
Buffedfile.mark (available ());
Read to Buffedfile, after read
Buffedfile.reset ();
Then you can continue to use Buffedfile. Otherwise you won't be able to use it anymore. This program is equivalent to starting with the first offset of the file stream, of course, if you read n bytes, then mark, then next time you reset, start using the file stream from N.
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////
Similar to the C language seek usage.
Randomfile = new Randomaccessfile ("FileName", "RW");
Long filelength = Randomfile.length ();
Randomfile.seek (100);
Operates on a file stream starting at offset 100.
。。。。。。。。。。。。。。。。。