code: public static Object pollFile(File file, int timeout, int interval)
              throws InterruptedException {
          // Convert time from s to ms for Thread
          int fullTimeout = Math.round(timeout * 1000);
  
          // Split up the timeout to poll every x amount of time
          int timeoutShard = Math.round(fullTimeout / interval);
  
          // Poll until file exists, return if it exists
          for (int i = 0; i < interval; i++) {
              Thread.sleep(timeoutShard);
              if (file.exists()) {
                  return readObjectFromFile(file);
              }
          }
  
          // Return null if time is up and still no file
          return null;
      }
docs: Polls a file periodically until it 1) exists or 2) the timeout is
  exceeded (returns null) Reads the file as a java Object