Revision as of 06: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

Recent Math PhD now doing a post-doctorate at UC Riverside.

Kuei-Nuan Lin