APISonar


com.google.common.io.Files.createParentDirs

> com > google > common > io > Files > createParentDirs
com APIs google APIs common APIs io APIs Files APIs createParentDirs APIs

Example 1
private File createOutputFile(String fileName)
            throws IOException
    {
        File outputFile = new File(fileName);
        Files.createParentDirs(outputFile);
        return outputFile;
    }
Example 2
private OutputSupplier<FileOutputStream> newOutputStreamSupplier(final File file)
    {
        return new OutputSupplier<FileOutputStream>()
        {
            public FileOutputStream getOutput()
                    throws IOException
            {
                Files.createParentDirs(file);
                return new FileOutputStream(file);
            }
        };
    }
Example 3
private Path credentailFilePath(String fileName) throws IOException {
        Path path = Paths.get(workspace.toString(), "credentials", fileName);
        Files.createParentDirs(path.toFile());
        return path;
    }
Example 4
public MockLocalStorageManager(File storageFolder)
            throws IOException
    {
        this.storageFolder = storageFolder;
        Files.createParentDirs(this.storageFolder);
        this.storageFolder.deleteOnExit();
    }
Example 5
private void createDirectoryStructureIfNotExists(final File dir) throws IOException {
        if (!dir.exists()) {
            try {
                Files.createParentDirs(new File(dir, DUMMY_FILE_NAME));
            } catch (final IOException e) {
                throw new IOException("Failed to create directory: " + dir.getAbsolutePath(), e);
            }
        } else if (!dir.isDirectory()) {
            throw new IOException("This location is not a directory: " + dir.getAbsolutePath());
        }
    }
Example 6
public static void createSourceJsonFile(File sourceJsonFile) throws IOException {
    Files.createParentDirs(sourceJsonFile);
    Files.write(SOURCE_JSON_DOCS, sourceJsonFile, ConfigurationKeys.DEFAULT_CHARSET_ENCODING);
  }
Example 7
public void save(File file) throws IOException {
        Validate.notNull(file, "File cannot be null");

        Files.createParentDirs(file);

        String data = saveToString();

        Writer writer = new OutputStreamWriter(new FileOutputStream(file), UTF8_OVERRIDE && !UTF_BIG ? Charsets.UTF_8 : Charset.defaultCharset());

        try {
            writer.write(data);
        } finally {
            writer.close();
        }
    }
Example 8
public void save(String siddhiAppName, String revision, byte[] snapshot) {
        File file = new File(folder + File.separator + siddhiAppName + File.separator + revision);
        try {
            Files.createParentDirs(file);
            Files.write(snapshot, file);
            cleanOldRevisions(siddhiAppName);
            if (log.isDebugEnabled()) {
                log.debug("Periodic persistence of " + siddhiAppName + " persisted successfully.");
            }
        } catch (IOException e) {
            log.error("Cannot save the revision " + revision + " of SiddhiApp: " + siddhiAppName +
                    " to the file system.", e);
        }
    }
Example 9
public String provideLogcatFile(@SpongeOutputDirectory String outputDir) throws IOException {
    File logdir = new File(outputDir, "device_logcat");
    if (!logdir.exists()) {
      Files.createParentDirs(logdir);
      logdir.mkdir();
    }
    return File.createTempFile("logcat", ".txt", logdir).getAbsolutePath();
  }
Example 10
public void saveToLocal() {
        try {
            Files.createParentDirs(localCache);
            Writer writer = Files.newWriter(localCache, Charsets.UTF_8);
            gson.toJson(metas.withoutNull(), Metas.class, writer);
            writer.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
Example 11
private void writeToFile(final String fileContents, final String relativePath)
      throws IOException {
    final File f = new File(relativePath);
    Files.createParentDirs(f);
    if (!f.createNewFile()) {
      throw new IllegalStateException("Cannot create file at " + f.getAbsolutePath());
    }
    Files.write(fileContents.getBytes(Charsets.UTF_8), f);
    log.info("Wrote to file at {}", f.getAbsolutePath());
  }
Example 12
public ColumnFileHandle createStagingFileHandles(UUID shardUuid, List<RaptorColumnHandle> columnHandles)
            throws IOException
    {
        File shardPath = getShardPath(baseStagingDir, shardUuid);

        ColumnFileHandle.Builder builder = ColumnFileHandle.builder(shardUuid, blockEncodingSerde);

        for (RaptorColumnHandle columnHandle : columnHandles) {
            File file = getColumnFile(shardPath, columnHandle, defaultEncoding);
            Files.createParentDirs(file);
            builder.addColumn(columnHandle, file, defaultEncoding);
        }

        return builder.build();
    }
Example 13
private void createGitRepoIfRequired() throws IOException {
    if (gitRepoTargetDir != null) {
      File gitFolder = new File(gitRepoTargetDir, ".git");
      FileUtils.copyDirectory(gitRepoSourceDir, gitFolder);
      // As the WITH_NO_CHANGES and WITH_CHANGES git trees contain empty
      // folders whose existence is crucial for the native git to run (jgit does not mind)
      // *and* because empty folders are silently omitted from git checkins, ensure that
      // these folders exist
      Files.createParentDirs(new File(gitFolder, "refs/heads"));
      Files.createParentDirs(new File(gitFolder, "refs/tags"));
    }
  }
Example 14
private static List<File> getOuputFiles(File shardPath, List<Long> columnIds)
            throws IOException
    {
        ImmutableList.Builder<File> files = ImmutableList.builder();
        for (long columnId : columnIds) {
            File file = getColumnFile(shardPath, columnId, BlocksFileEncoding.RAW);
            Files.createParentDirs(file);
            files.add(file);
        }
        return files.build();
    }
Example 15
public static void createFile(@NonNull File file, @NonNull String content) throws IOException {
        checkArgument(!file.exists(), "%s exists already.", file);

        Files.createParentDirs(file);
        Files.write(content, file, Charsets.UTF_8);
    }
Example 16
public void setClusterMetadata(ClusterMetadata metadata) {
        try {
            Files.createParentDirs(CONFIG_FILE);
            mapper.writeValue(CONFIG_FILE, metadata);
            providerService.clusterMetadataChanged(new Versioned<>(metadata, CONFIG_FILE.lastModified()));
        } catch (IOException e) {
            Throwables.propagate(e);
        }
    }
Example 17
private void includeManifests() throws IOException {
    for (Entry<PathFragment, Artifact> manifest : this.manifests.entrySet()) {
      String path = manifest.getValue().getPath().getPathString();
      for (String line : Files.readLines(new File(path), Charset.defaultCharset())) {
        String[] fields = line.split(" ");
        String targetPath = sandboxPath.getPathString() + PathFragment.SEPARATOR_CHAR + fields[0];
        String sourcePath = fields[1];
        File source = new File(sourcePath);
        File target = new File(targetPath);
        Files.createParentDirs(target);
        Files.copy(source, target);
      }
    }
  }
Example 18
public void setClusterMetadata(ClusterMetadata metadata) {
        try {
            File configFile = new File(metadataUrl.replaceFirst("file://", ""));
            Files.createParentDirs(configFile);
            ClusterMetadataPrototype metadataPrototype = toPrototype(metadata);
            mapper.writeValue(configFile, metadataPrototype);
            cachedMetadata.set(fetchMetadata(metadataUrl));
            providerService.clusterMetadataChanged(new Versioned<>(metadata, configFile.lastModified()));
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }
Example 19
public void write(ClusterDefinition definition) throws IOException {
        checkNotNull(definition);
        // write back to file
        Files.createParentDirs(file);
        ObjectMapper mapper = new ObjectMapper();
        mapper.writeValue(file, definition);
    }
Example 20
private void writeGraph(Graph g, Set<Node> unshared, File file) throws IOException, CommandException {
        Files.createParentDirs(output);
        Closer close = Closer.create();
        try {
            FileWriter writer = close.register(new FileWriter(file));
            GraphWriter gw = close.register(new GraphWriter(writer));
            renderGraph(g, unshared, gw);
        } catch (Throwable th) {
            throw close.rethrow(th, CommandException.class);
        } finally {
            close.close();
        }
    }
Example 21
public static CSVWriter open(File file, TableLayout layout, CompressionMode compression) throws IOException {
        Files.createParentDirs(file);
        Writer writer = LKFileUtils.openOutput(file, Charset.defaultCharset(), compression);
        try {
            return new CSVWriter(writer, layout);
        } catch (Throwable th) {
            try {
                writer.close();
            } catch (Throwable th2) {
                th.addSuppressed(th2);
            }
            Throwables.propagateIfInstanceOf(th, IOException.class);
            throw Throwables.propagate(th);
        }
    }
Example 22
static void createEmptyZip(File file) throws IOException {
    Files.createParentDirs(file);
    CustomZipOutputStream out = ZipOutputStreams.newOutputStream(file);
    // Sun's java 6 runtime doesn't allow us to create a truly empty zip, but this should be enough
    // to pass through dx/split-zip without any issue.
    // ...and Sun's java 7 runtime doesn't let us use an empty string for the zip entry name.
    out.putNextEntry(new ZipEntry("proguard_no_result"));
    out.close();
  }