Here is my sample code:
public static void main(String[] args) throws IOException {
FileInputStream a = new FileInputStream("/tmp/input");
File file = new File("/tmp/input");
try {
boolean isFileDeleted = file.delete();
System.out.println("Is file deleted successfully : "+ isFileDeleted);
} catch (Exception e) {
e.printStackTrace();
}
FileOutputStream outputStream = new FileOutputStream("/tmp/output");
IOUtils.copyLarge(a, outputStream);
}
Output:
Is file deleted successfully: true
And I am seeing the input file is deleted successfully also from /tmp
folder and I am also seeing output
file got created with the expected output. How FileInputStream read the File and copy the expected character even if the file is deleted from the disk?