I want to delete newline character from a text file.Surely,a straight forward way would be to read the characters one by one and write it in another file,if it finds a newline it would not write it in the second file.But I just want to delete the newline character in the first file without using any second file.How to do it?
Basically a file is modelled as an array of bytes. This isn't just a Java idea, this is how operating systems look at files.
So if you want to delete one of the bytes in a file, you then have to move all of the bytes which are to the "right" of that byte one position to the "left". This can be tedious if the file is very large, or if you're accessing it over a network. That's why everybody just does it the straightforward way, copy only the data you want to a new file.
subject: how to delete new line characters in java