protected void waitForFileToGrow(File file) throws Exception {
  int currentWaitTime=0;
  while (!file.exists()) {
    Log.i(LOG_TAG,"Waiting for file to exist...");
    currentWaitTime=timeoutWait(currentWaitTime,WAIT_FOR_DOWNLOAD_POLL_TIME,MAX_WAIT_FOR_DOWNLOAD_TIME,"Timed out waiting for file to be created.");
  }
  long originalSize=file.length();
  while (file.length() <= originalSize) {
    Log.i(LOG_TAG,"Waiting for file to be written to...");
    currentWaitTime=timeoutWait(currentWaitTime,WAIT_FOR_DOWNLOAD_POLL_TIME,MAX_WAIT_FOR_DOWNLOAD_TIME,"Timed out waiting for file to be written to.");
  }
}

protected void waitForFileToGrow ( File file ) throws Exception { int currentWaitTime = 0 ; while ( ! file . exists ( ) ) { Log . i ( LOG_TAG , "Waiting for file to exist..." ) ; currentWaitTime = timeoutWait ( currentWaitTime , WAIT_FOR_DOWNLOAD_POLL_TIME , MAX_WAIT_FOR_DOWNLOAD_TIME , "Timed out waiting for file to be created." ) ; } long originalSize = file . length ( ) ; while ( file . length ( ) <= originalSize ) { Log . i ( LOG_TAG , "Waiting for file to be written to..." ) ; currentWaitTime = timeoutWait ( currentWaitTime , WAIT_FOR_DOWNLOAD_POLL_TIME , MAX_WAIT_FOR_DOWNLOAD_TIME , "Timed out waiting for file to be written to." ) ; } }
synchronously waits for a file to increase in size ( such as to monitor that a download is progressing ) .
