Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug of java io?



Hi all,
  With the below code, I found that the file's lastModified time is
not changed. This code prints 8 same time numeric. But I've tested
this on other platform, like windows, linux, both work well, with
outputing different time numeric. Any idea about this?

Best regards,
Evan JIANG

import java.io.File;
import java.io.FileOutputStream;

public class test {

	static File _tmpFile;

	public static void main(String[] args) {
		try {
			_tmpFile = File.createTempFile("abc", ".txt");
			generateData("a");
			generateData("b");
			generateData("c");
			generateData("d");
		} catch (Exception e) {
			System.err.println(e);
		}
	}

	private static void generateData(String data) throws Exception {
		FileOutputStream fos = new FileOutputStream(_tmpFile);
		fos.write(data.getBytes());
		fos.close();
		System.err.println(_tmpFile.lastModified());
		_tmpFile = new File(_tmpFile.getAbsolutePath());
		System.err.println(_tmpFile.lastModified());
	}
}
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.