0

I have a large (around 50k+ lines). DAT file. I need to add one line before the last line in it.

When I am using:

Files.write(path, content.getBytes(StandardCharsets.UTF_8),
                StandardOpenOption.APPEND);

It is appending line after the last line.

Is there any way I can insert the line before the last line?

QualityMatters
  • 895
  • 11
  • 31
  • How about to use binary mode? – ghchoi Feb 06 '21 at 12:27
  • 1
    `.DAT` means to me a data file. A data file is usually not a text file and a file that is not a text file does not have lines. Does your file contain text only? Can I open your file in a text editor, like [Notepad](https://en.wikipedia.org/wiki/Microsoft_Notepad) or [vim](https://www.vim.org/) and read its contents? – Abra Feb 06 '21 at 12:39
  • Yes. This file can be open in Notepad++, and the file is having readable text – QualityMatters Feb 06 '21 at 15:07
  • @ghchoi : can you elaborate more? – QualityMatters Feb 06 '21 at 15:13

0 Answers0