import java.io.FileReader;
public class SimpoTest {
public static void main(String[] args) {
FileReader fileReader = null;
try {
fileReader = new FileReader("/home/brian/Desktop/me");
int read = fileReader.read();
System.out.println((char) read);
} catch (Exception e) {
fileReader = null;
e.printStackTrace();
}
}
}
1\ echo “1” > /home/brian/Desktop/me
2\ set the breakpoint to “int read = fileReader.read();”
3\ start the debug
4\ rm -f /home/brian/Desktop/me
5\ jump to the end <======== the “1” still outputted on the console…
well…this is really weird to me. as i though there should be an exception thrown out.
can anyone give any explanation?
any comments or suggestions are appreciated.
This is expected behavior at least on a unix-like operating system: as long as there’s an open file descriptor to it, the rm’d file’s blocks will remain allocated and accessible via that file descriptor.
I expect you cannot, however, open a new file descriptor to them by means of the deleted filename.