1

Sort of like Get/delete last character of file without loading into memory but in java.

I'm working on a json parser in java where the file would always end in }, but in order to write more information into the json file, it must be removed.

The only ways I know of doing this either involves loading the entire file in memory or transferring all the data to a temporary file just to get rid of a single character, which would be impractical when working with very large files.

Rain
  • 37
  • 6
  • You can use RandomAccessFile... Read a buffer, modify it (replace '}' by white-space/' ') and write back... But, why wouldn't collect a number of files instead of one single file? This should simplify the process and, for example, you may parallelize the parsing easily... – AnatolyG Nov 20 '20 at 14:51
  • I'm using the json file to store URLs, and slashes are not allowed in the file name – Rain Nov 20 '20 at 17:39

0 Answers0