Java how to copy part of a file
Posted
by
user3479074
on Stack Overflow
See other posts from Stack Overflow
or by user3479074
Published on 2014-08-06T19:47:58Z
Indexed on
2014/08/23
22:21 UTC
Read the original article
Hit count: 256
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?
© Stack Overflow or respective owner