当前位置: 首页>>代码示例>>Java>>正文


Java Files.createParentDirs方法代码示例

本文整理汇总了Java中com.google.common.io.Files.createParentDirs方法的典型用法代码示例。如果您正苦于以下问题:Java Files.createParentDirs方法的具体用法?Java Files.createParentDirs怎么用?Java Files.createParentDirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.io.Files的用法示例。


在下文中一共展示了Files.createParentDirs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepare

import com.google.common.io.Files; //导入方法依赖的package包/类
private void prepare(File bundleFile, File exploderDir, boolean hasInnerJar) {
    getLogger().info("prepare bundle " + bundleFile.getAbsolutePath());

    if (exploderDir.exists()) {
        return;
    }

    LibraryCache.unzipAar(bundleFile, exploderDir, getProject());
    if (hasInnerJar) {
        // verify the we have a classes.jar, if we don't just create an empty one.
        File classesJar = new File(new File(exploderDir, "jars"), "classes.jar");
        if (classesJar.exists()) {
            return;
        }
        try {
            Files.createParentDirs(classesJar);
            JarOutputStream jarOutputStream = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(
                classesJar)), new Manifest());
            jarOutputStream.close();
        } catch (IOException e) {
            throw new RuntimeException("Cannot create missing classes.jar", e);
        }
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:25,代码来源:PrepareAwoBundleTask.java

示例2: runManifestChangeVerifier

import com.google.common.io.Files; //导入方法依赖的package包/类
@VisibleForTesting
static void runManifestChangeVerifier(AppVariantContext appVariantContext, File SupportDir,
                                      @NonNull File manifestFileToPackage) throws IOException {
    File previousManifestFile = new File(SupportDir, "manifest.xml");
    if (previousManifestFile.exists()) {
        String currentManifest = Files.asCharSource(manifestFileToPackage, Charsets.UTF_8).read();
        String previousManifest = Files.asCharSource(previousManifestFile, Charsets.UTF_8).read();
        if (!currentManifest.equals(previousManifest)) {
            // TODO: Deeper comparison, call out just a version change.
            Files.copy(manifestFileToPackage, previousManifestFile);
        }
    } else {
        Files.createParentDirs(previousManifestFile);
        Files.copy(manifestFileToPackage, previousManifestFile);
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:17,代码来源:CheckManifestInIncrementalMode.java

示例3: setup

import com.google.common.io.Files; //导入方法依赖的package包/类
@Before
public void setup() throws IOException, InterruptedException {
  if (!WORK_DIR.isDirectory()) {
    Files.createParentDirs(new File(WORK_DIR, "dummy"));
  }

  // write out a few files
  for (int i = 0; i < 4; i++) {
    File fileName = new File(WORK_DIR, "file" + i);
    StringBuilder sb = new StringBuilder();

    // write as many lines as the index of the file
    for (int j = 0; j < i; j++) {
      sb.append("file" + i + "line" + j + "\n");
    }
    Files.write(sb.toString(), fileName, Charsets.UTF_8);
  }
  Thread.sleep(1500L); // make sure timestamp is later
  Files.write("\n", new File(WORK_DIR, "emptylineFile"), Charsets.UTF_8);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:TestReliableSpoolingFileEventReader.java

示例4: save

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * Saves this {@link FileConfiguration} to the specified location.
 * <p>
 * If the file does not exist, it will be created. If already exists, it
 * will be overwritten. If it cannot be overwritten or created, an
 * exception will be thrown.
 * <p>
 * This method will save using the system default encoding, or possibly
 * using UTF8.
 *
 * @param file File to save to.
 * @throws IOException              Thrown when the given file cannot be written to for
 *                                  any reason.
 * @throws IllegalArgumentException Thrown when file is null.
 */
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();
    }
}
 
开发者ID:avaire,项目名称:avaire,代码行数:31,代码来源:FileConfiguration.java

示例5: createTestFiles

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * Creates a directory tree of test files. To signify creating a directory
 * file path should end with '/'.
 *
 * @param paths   list of file paths
 * @param minSize minimum file size in bytes
 * @param maxSize maximum file size in bytes
 * @return list of created files
 * @throws java.io.IOException if there is an issue
 */
public static List<File> createTestFiles(List<String> paths,
                                         int minSize, int maxSize) throws IOException {
    ImmutableList.Builder<File> files = ImmutableList.builder();
    for (String p : paths) {
        File f = new File(p);
        if (p.endsWith("/")) {
            if (f.mkdirs()) {
                files.add(f);
            }
        } else {
            Files.createParentDirs(f);
            if (f.createNewFile()) {
                writeRandomFile(f, minSize, maxSize);
                files.add(f);
            }
        }
    }
    return files.build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:TestTools.java

示例6: extractProjectFiles

import com.google.common.io.Files; //导入方法依赖的package包/类
private ArrayList<String> extractProjectFiles(ZipFile inputZip, File projectRoot)
    throws IOException {
  ArrayList<String> projectFileNames = Lists.newArrayList();
  Enumeration<? extends ZipEntry> inputZipEnumeration = inputZip.entries();
  while (inputZipEnumeration.hasMoreElements()) {
    ZipEntry zipEntry = inputZipEnumeration.nextElement();
    final InputStream extractedInputStream = inputZip.getInputStream(zipEntry);
    File extractedFile = new File(projectRoot, zipEntry.getName());
    LOG.info("extracting " + extractedFile.getAbsolutePath() + " from input zip");
    Files.createParentDirs(extractedFile); // Do I need this?
    Files.copy(
        new InputSupplier<InputStream>() {
          public InputStream getInput() throws IOException {
            return extractedInputStream;
          }
        },
        extractedFile);
    projectFileNames.add(extractedFile.getPath());
  }
  return projectFileNames;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:22,代码来源:ProjectBuilder.java

示例7: saveDataToFile

import com.google.common.io.Files; //导入方法依赖的package包/类
private void saveDataToFile(LoadData data, String dnName) {
    if (data.getFileName() == null) {
        String dnPath = tempPath + dnName + ".txt";
        data.setFileName(dnPath);
    }

    File dnFile = new File(data.getFileName());
    try {
        if (!dnFile.exists()) {
            Files.createParentDirs(dnFile);
        }
        Files.append(joinLine(data.getData(), data), dnFile, Charset.forName(loadData.getCharset()));

    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        data.setData(null);
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:20,代码来源:ServerLoadDataInfileHandler.java

示例8: save

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * Saves this {@link .FileConfiguration} to the specified location.
 * <p/>
 * If the file does not exist, it will be created. If already exists, it
 * will be overwritten. If it cannot be overwritten or created, an
 * exception will be thrown.
 * <p/>
 * This method will save using the system default encoding, or possibly
 * using UTF8.
 *
 * @param file File to save to.
 * @throws java.io.IOException      Thrown when the given file cannot be written to for
 *                                  any reason.
 * @throws IllegalArgumentException Thrown when file is null.
 */
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();
	}
}
 
开发者ID:ZP4RKER,项目名称:zlevels,代码行数:33,代码来源:FileConfiguration.java

示例9: saveDataToFile

import com.google.common.io.Files; //导入方法依赖的package包/类
private void saveDataToFile(LoadData data,String dnName)
{
    if (data.getFileName() == null)
    {
        String dnPath = tempPath + dnName + ".txt";
        data.setFileName(dnPath);
    }

       File dnFile = new File(data.getFileName());
        try
        {
            if (!dnFile.exists()) {
                                    Files.createParentDirs(dnFile);
                                }
                       	Files.append(joinLine(data.getData(),data), dnFile, Charset.forName(loadData.getCharset()));

        } catch (IOException e)
        {
            throw new RuntimeException(e);
        }finally
        {
            data.setData(null);

        }



}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:29,代码来源:ServerLoadDataInfileHandler.java

示例10: copyFileOut

import com.google.common.io.Files; //导入方法依赖的package包/类
public void copyFileOut(String containerId, File output, String pathInContainer)
		throws DockerException, InterruptedException, IOException {
	File temp = new File(output.getParent() + File.separator + "_temp.tar");
	Files.createParentDirs(temp);
	if (!temp.createNewFile())
		throw new IOException("can not new temp file: " + temp.toString());
	TarArchiveOutputStream aos = new TarArchiveOutputStream(new FileOutputStream(temp));
	try (final TarArchiveInputStream tarStream = new TarArchiveInputStream(
			client.archiveContainer(containerId, pathInContainer))) {
		TarArchiveEntry entry;
		while ((entry = tarStream.getNextTarEntry()) != null) {
			aos.putArchiveEntry(entry);
			IOUtils.copy(tarStream, aos);
			aos.closeArchiveEntry();
		}
	}
	aos.finish();
	aos.close();
	boolean unTarStatus = unTar(new TarArchiveInputStream(new FileInputStream(temp)), output.getParent());
	StringBuilder builder = new StringBuilder();
	if (!unTarStatus)
		throw new RuntimeException("un tar file error");
	if (!temp.delete())
		builder.append("temp file delete failed, but ");
	LOGGER.info(builder.append("copy files ").append(pathInContainer).append(" out of container ")
			.append(containerId).append(" successful").toString());
}
 
开发者ID:ProgramLeague,项目名称:Avalon-Executive,代码行数:28,代码来源:DockerOperator.java

示例11: setup

import com.google.common.io.Files; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
  Files.createParentDirs(new File(WORK_DIR, "dummy"));
  file = File.createTempFile(getClass().getSimpleName(), ".txt", WORK_DIR);
  logger.info("Data file: {}", file);
  meta = File.createTempFile(getClass().getSimpleName(), ".avro", WORK_DIR);
  logger.info("PositionTracker meta file: {}", meta);
  meta.delete(); // We want the filename but not the empty file
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:10,代码来源:TestResettableFileInputStream.java

示例12: moveDirToInstall

import com.google.common.io.Files; //导入方法依赖的package包/类
private void moveDirToInstall(File pluginsDir, String destination) throws IOException
{
	Path installPath = config.getInstallDir().toPath();
	Path fullDest = installPath.resolve(destination);
	FileUtils.delete(fullDest.toFile());
	Files.createParentDirs(fullDest.toFile());
	org.apache.commons.io.FileUtils.moveDirectoryToDirectory(pluginsDir, fullDest.toFile(), true);
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:Deployer.java

示例13: moveToInstall

import com.google.common.io.Files; //导入方法依赖的package包/类
private void moveToInstall(File source, String destination) throws IOException
{
	Path installPath = config.getInstallDir().toPath();
	Path fullDest = installPath.resolve(destination);
	ajax.addBasic(ajaxId, "Copying: " + source.getPath() + " to: " + fullDest);
	FileUtils.delete(fullDest.toFile());
	Files.createParentDirs(fullDest.toFile());
	Files.move(source, fullDest.toFile());
}
 
开发者ID:equella,项目名称:Equella,代码行数:10,代码来源:Deployer.java

示例14: createParentDirs

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * Create any parent directories that do not exist in the specified file's path.
 *
 * @param file The file
 */
public static void createParentDirs(File file) {
    try {
        Files.createParentDirs(file);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:DianoxDragon,项目名称:UltimateSpawn,代码行数:13,代码来源:FileUtils.java

示例15: setClusterMetadata

import com.google.common.io.Files; //导入方法依赖的package包/类
@Override
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);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:ConfigFileBasedClusterMetadataProvider.java


注:本文中的com.google.common.io.Files.createParentDirs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。