If I create a java Random Access File object against a file. What happens when the file is renamed?
case1. Let’s say, I created a RAF object against test.log. Then I renamed test.log -> test1.log by doing something like
mv test.log test1.log
What happens to my RAF object then in this case?
case2. again, create a RAF object against test.log then:
mv test.log test1.log
touch test.log
in this case, is my object pointing to test.log or test1.log
case3. what if my RAF object is pointing to a log file which will be rotated eventually?
Most importantly, can someone explain to me what happens under the cover? like how the RAF object points/refers to the actual file, how it works when file is renamed or deleted.
===========================
My Own test
===========================
test case 1:
remove the test_log file after lineA before lineB, it finishes reading the whole file without any problems/Exceptions.
test case 2:
mv /tmp/test_log /tmp/test_log.bk after lineA before lineB, again,it finishes reading the whole file without any problems/Exceptions.
test case 3:
following test case 2, start writing extra lines to /tmp/test_log.bk,
it reads the whole file now problem, PLUS, it reads the new lines added in test_log.bk as well.