Runing the codes on Create TAR Files Using Apache Ant API, the following exception may be thrown when processing a file still being appended or modified.
request to write '1024' bytes exceeds size in header
of '-2088094749' bytes java.io.IOException: request
to write '1024' bytes exceeds size in header of '-2
To reproduce the similar issue, create a non-empty file referred to by the path variable.
Upon seeing the lines below displayed on the console, update the contents of the file immediately.
Thread is sleeping.
You may now append the file.
After 10 seconds, the exception is thrown from the console.
What exactly happened? Let us say on the first reading, the codes determine the file size is 7 kB. However, after the file update, right before the second file read, the file size changes. Thus, the IOException exception.