Which class in java can read and write files at the same time?

I learned the PrintWritere class and the Scanner class
, the assignment is to turn a minor line style java program into a line end style
, or to replace all the substrings of "n {" in a java text file with "{"
, but the Scanner class does not rea dna t all and skips the character
, and even if I find it, I only learn that the PrintWriter class can write text in the new file after the old file. I simply do not know how to replace the original text
, so I can only create a new temporary text to write the modified content of the java file with the PringWriter object, delete the original file and rename the temporary file
. Is there a more convenient way to do this?

Mar.11,2021

it is impossible to read and write at the same time, so there will be a problem. So you will find that the basic way to replace the contents of a file is to save the replaced content to the new file, and then overwrite the old file, such as the sed-I command. If the documents could be read and written at the same time, they would have done so.

for some principles and explanations, please refer to this: https://stackoverflow.com/que.

if you just append content, such as log , this can be read and written at the same time, but it is impossible to edit and modify it. For example, sed-I


the reading and writing of the java file is locked on the file, as well as at the operating system level. So reading and writing at the same time should not work at the lock level.


RandomAccessFile

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3773f-2c0ac.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3773f-2c0ac.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?