Revision as of 07:49, 4 December 2010 by Han84 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
/**
 * Wait until the file is ready.
 * @param filename
 * @param timeout in millisecond
 * @return
 */
public static boolean fileWait(String filename, int timeout) {
	long start_time = System.currentTimeMillis();
	java.io.File file = new java.io.File(filename);
	while (!file.canRead()) {
		Ts.threadSleep(2);
		if ((System.currentTimeMillis() - start_time) > timeout) {
			return false;
		}
	}
	return true;
}


Back to JavaHowTo

Alumni Liaison

Followed her dream after having raised her family.

Ruth Enoch, PhD Mathematics