public void saveToFile(File file) throws IOException {
    try {
      _writeToFile(file, this);
    }
    catch (IOException e) {
      // assuming the reason is non-existing parent
      final File parentFile = file.getParentFile();
      if (parentFile == null) {
        throw e;
      }
      //noinspection ResultOfMethodCallIgnored
      parentFile.mkdirs();
      // second attempt
      _writeToFile(file, this);
    }
  }
public void saveToFile(File file)