/**
  * Build and return a temporary file in the same directory and with the same extension as the
  * specified file.
  */
 protected File buildTempFile(File file) throws IOException {
   int i = file.getName().lastIndexOf('.');
   String ext = ((i == -1) ? ".zip" : file.getName().substring(i));
   File tempFile = File.createTempFile("temp", ext, file.getParentFile());
   return tempFile;
 }