/**
 * 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

To all math majors: "Mathematics is a wonderfully rich subject."

Dr. Paul Garrett