APISonar


com.google.common.io.Files.move

> com > google > common > io > Files > move
com APIs google APIs common APIs io APIs Files APIs move APIs

Example 1
private void persistEventTypeIdMap() {
    //noinspection ResultOfMethodCallIgnored
    new File(filename).getParentFile().mkdirs();
    String newFilename = filename + ".new";
    try {
      try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(newFilename))) {
        oos.writeObject(eventTypeIdMap);
      }
      Files.move(new File(newFilename), new File(filename));
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
Example 2
protected boolean rename(String src, String dst) {
    try {
      Files.move(new File(src), new File(dst));
      return true;
    } catch (IOException e) {
      LOG.error("Cannot rename {} to {}", src, dst, e);
      return false;
    }
  }
Example 3
private File createTmpDirWithRandomFiles(File parentDir) throws IOException {
    File dir = Files.createTempDir();
    for (int i = 0; i < NUM_FILES; i++) {
      File f = new File(dir, ""+i+".txt");
      f.createNewFile();

      BufferedWriter w = new BufferedWriter(new FileWriter(f));
      w.write(RandomStringUtils.randomAlphanumeric(1024));
      w.close();
    }

    File tmp = new File(parentDir, dir.getName());
    Files.move(dir, tmp);
    return tmp;
  }
Example 4
private void generateRefreshJarFiles(String version) throws IOException, InterruptedException {
    String u = HiveTestUtils
        .getFileFromClasspath(RELOADED_CLAZZ_PREFIX_NAME + version + HiveTestUtils.TXT_FILE_EXT);
    File jarFile = HiveTestUtils.genLocalJarForTest(u, RELOADED_CLAZZ_PREFIX_NAME);
    Files.move(jarFile, new File(jarFile.getAbsolutePath() + "." + version));
  }
Example 5
private void moveFileOutErr(ActionExecutionContext actionExecutionContext, FileOutErr outErr)
      throws IOException {
    if (outErr.getOutputPath().exists()) {
      Files.move(
          outErr.getOutputPath().getPathFile(),
          actionExecutionContext.getFileOutErr().getOutputPath().getPathFile());
    }
    if (outErr.getErrorPath().exists()) {
      Files.move(
          outErr.getErrorPath().getPathFile(),
          actionExecutionContext.getFileOutErr().getErrorPath().getPathFile());
    }
  }
Example 6
public void convertLegacyFile()
	{
		final File file = new File(configFile.getParentFile(), username + ".yml");
		try
		{
			Files.move(file, new File(configFile.getParentFile(), uuid + ".yml"));
		}
		catch (IOException ex)
		{
			Bukkit.getLogger().log(Level.WARNING, "Failed to migrate user: " + username, ex);
		}

		setProperty("lastAccountName", username);
	}
Example 7
private void copyOutputs(Collection<? extends ActionInput> outputs) throws IOException {
    for (ActionInput output : outputs) {
      Path source = sandboxExecRoot.getRelative(output.getExecPathString());
      Path target = execRoot.getRelative(output.getExecPathString());
      FileSystemUtils.createDirectoryAndParents(target.getParentDirectory());
      if (source.isFile()) {
        Files.move(new File(source.getPathString()), new File(target.getPathString()));
      }
    }
  }
Example 8
public void onJobCompletion(JobContext jobContext) {
    JobState jobState = jobContext.getJobState();
    if (!jobState.contains(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY)) {
      LOG.error("Job configuration file path not found in job state of job " + jobState.getJobId());
      return;
    }

    String jobConfigFile = jobState.getProp(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY);
    // Rename the config file so we won't run this job when the worker is bounced
    try {
      Files.move(new File(jobConfigFile), new File(jobConfigFile + ".done"));
    } catch (IOException ioe) {
      LOG.error("Failed to rename job configuration file for job " + jobState.getJobName(), ioe);
    }
  }
Example 9
public synchronized void writeCheckpoint(Dag<JobExecutionPlan> dag) throws IOException {
    // write to a temporary name then rename to make the operation atomic when the file system allows a file to be
    // replaced
    String fileName = DagManagerUtils.generateDagId(dag) + DAG_FILE_EXTENSION;
    String serializedDag = serializeDag(dag);

    File tmpCheckpointFile = new File(this.dagCheckpointDir, fileName + ".tmp");
    File checkpointFile = new File(this.dagCheckpointDir, fileName);

    Files.write(serializedDag, tmpCheckpointFile, Charsets.UTF_8);
    Files.move(tmpCheckpointFile, checkpointFile);
  }