Can I write the end of a 5GB file in Java?

Can I write the end of a 5GB file in Java? The question appeared in my office, and no one was sure what the answer was

Solution

This should be easily achieved using RandomAccessFile The following should be valid:

String filename;

RandomAccessFile myFile = new RandomAccessFile(filename,"rw");

// Set write pointer to the end of the file
myFile.seek(myFile.length());

// Write to end of file here
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>