I’m wondering what types of programmatic behaviors count as “modifying” a file in java. That is, what operations which i might perform on a file would cause the file.lastModified() call to change it’s value?
I.E. Opening? Reading? Writing? Copying? Writing is an obvious trigger, but the others aren’t so obvious. I’ve done some looking around online and not seen anything immediate.
Clarification: I’m not tyring to set the last modified time, i’m just attempting to determine what programmatic behaviors which a java program might engage in would cause this value to update. Obviously writing to a file would do this. But are there other cases which do cause this?
Reading depends on opening, Copying depends on reading. Writing is the only trigger to set the Last Modified stamp. Once you open a file, in most operating systems, you need to specify what modes you want to open the file with. e.g.
rworrorwora(append) etc. (implementation / os dependant). Sinceaincludesw,wis the only operation that will set the Last Modified stamp.Java classes (such as
FileInputStream) will open the file specifyingror “read” – so that won’t trigger the LastModified stamp. Java has distinct classes for Readers and Writers – Input and Output. The input/reader classes (Reader,InputStream) will not set the LastModified stamp. However, a simple Open-For-Write (without actually writing) will most likely also trigger the LastModified stamp, i.e.:will most likely trigger the LastModified set.
Regards.