I have to read a file and depending of the content of the last lines, I have to copy most of its content into a new file. Unfortunately I didn't found a way to copy first n lines or chars of a file in java.
The only way I found, is copying the file using nio FileChannels where I can specifiy the length in bytes. However, therefore I would need to know how many bytes the stuff I read needed in the source-file.
Does anyone know a solution for one of these problems?
The file to read contains only simple text. If I have to specify the number of lines or the number of chars to copy doesn't really matter (I can count both while reading the file).
Reading the file and write the needed content to another file would be possible but also slower than using another way of copying (like path, FileChannels...) and its important to copy as fast as possible – user3479074 Aug 06 '14 at 20:02