Java 类org.springframework.util.FileSystemUtils 实例源码

项目:spring-cloud-skipper    文件:DefaultPackageWriter.java   
@Override
public File write(Package pkg, File targetDirectory) {
    PackageMetadata packageMetadata = pkg.getMetadata();
    File tmpDir = TempFileUtils.createTempDirectory("skipper" + packageMetadata.getName()).toFile();
    File rootPackageDir = new File(tmpDir,
            String.format("%s-%s", packageMetadata.getName(), packageMetadata.getVersion()));
    rootPackageDir.mkdir();
    writePackage(pkg, rootPackageDir);
    if (!pkg.getDependencies().isEmpty()) {
        File packagesDir = new File(rootPackageDir, "packages");
        packagesDir.mkdir();
        for (Package dependencyPkg : pkg.getDependencies()) {
            File packageDir = new File(packagesDir, dependencyPkg.getMetadata().getName());
            packageDir.mkdir();
            writePackage(dependencyPkg, packageDir);
        }
    }
    File targetZipFile = PackageFileUtils.calculatePackageZipFile(pkg.getMetadata(), targetDirectory);
    ZipUtil.pack(rootPackageDir, targetZipFile, true);
    FileSystemUtils.deleteRecursively(tmpDir);
    return targetZipFile;
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageServiceTests.java   
@Before
public void setUp() throws IOException {
    operations.dropCollection(Image.class);

    operations.insert(new Image("1",
        "learning-spring-boot-cover.jpg"));
    operations.insert(new Image("2",
        "learning-spring-boot-2nd-edition-cover.jpg"));
    operations.insert(new Image("3",
        "bazinga.png"));

    FileSystemUtils.deleteRecursively(new File(ImageService.UPLOAD_ROOT));

    Files.createDirectory(Paths.get(ImageService.UPLOAD_ROOT));

    FileCopyUtils.copy("Test file",
        new FileWriter(ImageService.UPLOAD_ROOT +
            "/learning-spring-boot-cover.jpg"));

    FileCopyUtils.copy("Test file2",
        new FileWriter(ImageService.UPLOAD_ROOT +
            "/learning-spring-boot-2nd-edition-cover.jpg"));

    FileCopyUtils.copy("Test file3",
        new FileWriter(ImageService.UPLOAD_ROOT + "/bazinga.png"));
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
    return (args) -> {
        FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

        Files.createDirectory(Paths.get(UPLOAD_ROOT));

        FileCopyUtils.copy("Test file",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-cover.jpg"));

        FileCopyUtils.copy("Test file2",
            new FileWriter(UPLOAD_ROOT +
                "/learning-spring-boot-2nd-edition-cover.jpg"));

        FileCopyUtils.copy("Test file3",
            new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
    };
}
项目:gradle-initializr    文件:DefaultGradleInitializrService.java   
private byte[] createDownloadFile(Function<File, File> action) {
    Path tmpDir = null;

    try {
        tmpDir = createTempDir();

        if (logger.isDebugEnabled()) {
            logger.debug("Generating project in temporary directory " + tmpDir.toFile());
        }

        File download = action.apply(tmpDir.toFile());
        return fileToByteArray(download);
    } catch(Exception e) {
        throw new RuntimeException(e);
    } finally {
        if (tmpDir != null) {
            if (!FileSystemUtils.deleteRecursively(tmpDir.toFile())) {
                logger.warn("Unable to delete temporary directory " + tmpDir.toFile());
            }
        }
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ProjectCreator.java   
public ProjectConnection createProject(String name) throws IOException {
    File projectDirectory = new File("target/" + name);
    projectDirectory.mkdirs();

    File gradleScript = new File(projectDirectory, "build.gradle");

    if (new File("src/test/resources", name).isDirectory()) {
        FileSystemUtils.copyRecursively(new File("src/test/resources", name),
                projectDirectory);
    }
    else {
        FileCopyUtils.copy(new File("src/test/resources/" + name + ".gradle"),
                gradleScript);
    }

    GradleConnector gradleConnector = GradleConnector.newConnector();
    gradleConnector.useGradleVersion(this.gradleVersion);

    ((DefaultGradleConnector) gradleConnector).embedded(true);
    return gradleConnector.forProjectDirectory(projectDirectory).connect();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:WarLauncherTests.java   
@Test
public void explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath()
        throws Exception {
    File warRoot = new File("target/exploded-war");
    FileSystemUtils.deleteRecursively(warRoot);
    warRoot.mkdirs();
    File webInfClasses = new File(warRoot, "WEB-INF/classes");
    webInfClasses.mkdirs();
    File webInfLib = new File(warRoot, "WEB-INF/lib");
    webInfLib.mkdirs();
    File webInfLibFoo = new File(webInfLib, "foo.jar");
    new JarOutputStream(new FileOutputStream(webInfLibFoo)).close();
    WarLauncher launcher = new WarLauncher(new ExplodedArchive(warRoot, true));
    List<Archive> archives = launcher.getClassPathArchives();
    assertThat(archives).hasSize(2);
    assertThat(getUrls(archives)).containsOnly(webInfClasses.toURI().toURL(),
            new URL("jar:" + webInfLibFoo.toURI().toURL() + "!/"));
}
项目:spring-boot-concourse    文件:ProjectCreator.java   
public ProjectConnection createProject(String name) throws IOException {
    File projectDirectory = new File("target/" + name);
    projectDirectory.mkdirs();

    File gradleScript = new File(projectDirectory, "build.gradle");

    if (new File("src/test/resources", name).isDirectory()) {
        FileSystemUtils.copyRecursively(new File("src/test/resources", name),
                projectDirectory);
    }
    else {
        FileCopyUtils.copy(new File("src/test/resources/" + name + ".gradle"),
                gradleScript);
    }

    GradleConnector gradleConnector = GradleConnector.newConnector();
    gradleConnector.useGradleVersion(this.gradleVersion);

    ((DefaultGradleConnector) gradleConnector).embedded(true);
    return gradleConnector.forProjectDirectory(projectDirectory).connect();
}
项目:spring-boot-concourse    文件:WarLauncherTests.java   
@Test
public void explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath()
        throws Exception {
    File warRoot = new File("target/exploded-war");
    FileSystemUtils.deleteRecursively(warRoot);
    warRoot.mkdirs();
    File webInfClasses = new File(warRoot, "WEB-INF/classes");
    webInfClasses.mkdirs();
    File webInfLib = new File(warRoot, "WEB-INF/lib");
    webInfLib.mkdirs();
    File webInfLibFoo = new File(webInfLib, "foo.jar");
    new JarOutputStream(new FileOutputStream(webInfLibFoo)).close();
    WarLauncher launcher = new WarLauncher(new ExplodedArchive(warRoot, true));
    List<Archive> archives = launcher.getClassPathArchives();
    assertThat(archives).hasSize(2);
    assertThat(getUrls(archives)).containsOnly(webInfClasses.toURI().toURL(),
            new URL("jar:" + webInfLibFoo.toURI().toURL() + "!/"));
}
项目:contestparser    文件:ProjectCreator.java   
public ProjectConnection createProject(String name) throws IOException {
    File projectDirectory = new File("target/" + name);
    projectDirectory.mkdirs();

    File gradleScript = new File(projectDirectory, "build.gradle");

    if (new File("src/test/resources", name).isDirectory()) {
        FileSystemUtils.copyRecursively(new File("src/test/resources", name),
                projectDirectory);
    }
    else {
        FileCopyUtils.copy(new File("src/test/resources/" + name + ".gradle"),
                gradleScript);
    }

    GradleConnector gradleConnector = GradleConnector.newConnector();
    gradleConnector.useGradleVersion(this.gradleVersion);

    ((DefaultGradleConnector) gradleConnector).embedded(true);
    return gradleConnector.forProjectDirectory(projectDirectory).connect();
}
项目:contestparser    文件:WarLauncherTests.java   
@Test
public void explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath()
        throws Exception {
    File warRoot = new File("target/exploded-war");
    FileSystemUtils.deleteRecursively(warRoot);
    warRoot.mkdirs();
    File webInfClasses = new File(warRoot, "WEB-INF/classes");
    webInfClasses.mkdirs();
    File webInfLib = new File(warRoot, "WEB-INF/lib");
    webInfLib.mkdirs();
    File webInfLibFoo = new File(webInfLib, "foo.jar");
    new JarOutputStream(new FileOutputStream(webInfLibFoo)).close();

    WarLauncher launcher = new WarLauncher(new ExplodedArchive(warRoot, true));
    List<Archive> archives = launcher.getClassPathArchives();
    assertEquals(2, archives.size());

    assertThat(getUrls(archives), hasItems(webInfClasses.toURI().toURL(),
            new URL("jar:" + webInfLibFoo.toURI().toURL() + "!/")));
}
项目:parkovani-v-praze    文件:ShapeFileLoaderController.java   
@Override
public void run(String... args) throws Exception {

    FileSystemUtils.deleteRecursively(new File(dbDataDir));

    LOG.info("Creating Spatial alias");
    jdbcTemplate.execute("CREATE ALIAS IF NOT EXISTS SPATIAL_INIT FOR \"org.h2gis.h2spatialext.CreateSpatialExtension.initSpatialExtension\";");

    LOG.info("Initializing spatial extension");
    jdbcTemplate.execute("CALL SPATIAL_INIT();");

    loadData("DOP_ZPS_Stani_l_mercator.shp", "DOP_ZPS_Stani_l");
    loadData("DOP_ZachParkoviste_b_mercator.shp", "DOP_ZachParkoviste_b");
    loadData("DOP_ZachParkoviste_b_mercator-buffer20.shp", "DOP_ZachParkoviste_b_buffer20");
    loadData("DOP_ZPS_Automaty_b_mercator.shp", "DOP_ZPS_Automaty_b");
    loadData("DOP_ZPS_Automaty_b_mercator-buffer20.shp", "DOP_ZPS_Automaty_b_buffer20");

}
项目:whois    文件:RpslObjectsExporter.java   
public void export() {
    if (!enabled) {
        return;
    }
    if (exporting.getAndSet(true)) {
        throw new IllegalStateException("Export already in progress");
    }

    try {
        LOGGER.info("Database export started");
        final Stopwatch stopwatch = Stopwatch.createStarted();

        initDirs();
        exportToFiles();

        Validate.isTrue(FileSystemUtils.deleteRecursively(exportDir), "Recursive delete failed: ", exportDir);
        Validate.isTrue(tmpDir.renameTo(exportDir), "Rename failed: ", tmpDir);

        LOGGER.info("Database export complete after {} in {}", stopwatch.stop().toString(), exportDir);
    } finally {
        exporting.set(false);
    }
}
项目:whois    文件:RpslObjectsExporter.java   
private void initDirs() {
    if (exportDir.exists()) {
        Validate.isTrue(exportDir.canWrite(), "Unable to write to: ", exportDir);
        Validate.isTrue(exportFileWriterFactory.isExportDir(exportDir), "Existing dir does not have correct structure: ", exportDir);
        LOGGER.info("Use existing: {}", exportDir);
    } else {
        Validate.isTrue(exportDir.mkdirs(), "Unable to create export dir: ", exportDir);
        LOGGER.info("Created: {}", exportDir);
    }

    if (tmpDir.exists()) {
        Validate.isTrue(exportFileWriterFactory.isExportDir(tmpDir), "Existing dir does not have correct structure: ", tmpDir);
        Validate.isTrue(FileSystemUtils.deleteRecursively(tmpDir), "Unable to remove temp dir: ", tmpDir);
        LOGGER.info("Delete existing: {}", tmpDir);
    }

    Validate.isTrue(tmpDir.mkdirs(), "Unable to create temp dir: ", tmpDir);
    LOGGER.info("Created: {}", tmpDir);
}
项目:spring-cloud-skipper    文件:PackageService.java   
private Package deserializePackageFromDatabase(PackageMetadata packageMetadata) {
    // package file was uploaded to a local DB hosted repository
    Path tmpDirPath = null;
    try {
        tmpDirPath = TempFileUtils.createTempDirectory("skipper");
        File targetPath = new File(tmpDirPath + File.separator + packageMetadata.getName());
        targetPath.mkdirs();
        File targetFile = PackageFileUtils.calculatePackageZipFile(packageMetadata, targetPath);
        try {
            StreamUtils.copy(packageMetadata.getPackageFile().getPackageBytes(), new FileOutputStream(targetFile));
        }
        catch (IOException e) {
            throw new SkipperException(
                    "Could not copy package file for " + packageMetadata.getName() + "-"
                            + packageMetadata.getVersion() +
                            " from database to target file " + targetFile,
                    e);
        }
        ZipUtil.unpack(targetFile, targetPath);
        Package pkgToReturn = this.packageReader.read(new File(targetPath, packageMetadata.getName() + "-" +
                packageMetadata.getVersion()));
        pkgToReturn.setMetadata(packageMetadata);
        return pkgToReturn;
    }
    finally {
        if (tmpDirPath != null && !FileSystemUtils.deleteRecursively(tmpDirPath.toFile())) {
            logger.warn("Temporary directory can not be deleted: " + tmpDirPath);
        }
    }
}
项目:spring-cloud-skipper    文件:PackageService.java   
@Transactional
public PackageMetadata upload(UploadRequest uploadRequest) {
    validateUploadRequest(uploadRequest);
    Repository localRepositoryToUpload = getRepositoryToUpload(uploadRequest.getRepoName());
    Path packageDirPath = null;
    try {
        packageDirPath = TempFileUtils.createTempDirectory("skipperUpload");
        File packageDir = new File(packageDirPath + File.separator + uploadRequest.getName());
        packageDir.mkdir();
        Path packageFile = Paths
                .get(packageDir.getPath() + File.separator + uploadRequest.getName() + "-"
                        + uploadRequest.getVersion() + "." + uploadRequest.getExtension());
        Assert.isTrue(packageDir.exists(), "Package directory doesn't exist.");
        Files.write(packageFile, uploadRequest.getPackageFileAsBytes());
        ZipUtil.unpack(packageFile.toFile(), packageDir);
        String unzippedPath = packageDir.getAbsolutePath() + File.separator + uploadRequest.getName()
                + "-" + uploadRequest.getVersion();
        File unpackagedFile = new File(unzippedPath);
        Assert.isTrue(unpackagedFile.exists(), "Package is expected to be unpacked, but it doesn't exist");
        Package packageToUpload = this.packageReader.read(unpackagedFile);
        PackageMetadata packageMetadata = packageToUpload.getMetadata();
        if (localRepositoryToUpload != null) {
            packageMetadata.setRepositoryId(localRepositoryToUpload.getId());
            packageMetadata.setRepositoryName(localRepositoryToUpload.getName());
        }
        packageMetadata.setPackageFile(new PackageFile((uploadRequest.getPackageFileAsBytes())));
        return this.packageMetadataRepository.save(packageMetadata);
    }
    catch (IOException e) {
        throw new SkipperException("Failed to upload the package.", e);
    }
    finally {
        if (packageDirPath != null && !FileSystemUtils.deleteRecursively(packageDirPath.toFile())) {
            logger.warn("Temporary directory can not be deleted: " + packageDirPath);
        }
    }
}
项目:edoras-one-initializr    文件:ProjectGenerator.java   
/**
 * Clean all the temporary files that are related to this root directory.
 * @see #createDistributionFile
 */
public void cleanTempFiles(File dir) {
    List<File> tempFiles = temporaryFiles.remove(dir.getName());
    if (!tempFiles.isEmpty()) {
        tempFiles.forEach((File file) -> {
            if (file.isDirectory()) {
                FileSystemUtils.deleteRecursively(file);
            }
            else if (file.exists()) {
                file.delete();
            }
        });
    }
}
项目:Breakpoint-http    文件:StorageServiceImpl.java   
@Override
public void deleteAll() {
    logger.info("开发初始化清理数据,start");
    FileSystemUtils.deleteRecursively(rootPaht.toFile());
    stringRedisTemplate.delete(Constants.FILE_UPLOAD_STATUS);
    stringRedisTemplate.delete(Constants.FILE_MD5_KEY);
    logger.info("开发初始化清理数据,end");
}
项目:spring-cloud-release-tools    文件:ProjectBuilderTests.java   
@Before
public void checkOs() throws Exception {
    Assume.assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win"));
    this.temporaryFolder = this.tmp.newFolder();
    TestUtils.prepareLocalRepo();
    FileSystemUtils.copyRecursively(file("/projects"), this.temporaryFolder);
}
项目:spring-cloud-release-tools    文件:AcceptanceTests.java   
@Before
public void setup() throws Exception {
    this.temporaryFolder = this.tmp.newFolder();
    this.springCloudConsulProject = new File(AcceptanceTests.class.getResource("/projects/spring-cloud-consul").toURI());
    TestUtils.prepareLocalRepo();
    FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder);
}
项目:syndesis    文件:LocalProcessVerifier.java   
private String getConnectorClasspath(Connector connector) throws IOException, InterruptedException {
    byte[] pom = new byte[0]; // TODO: Fix generation to use an Action projectGenerator.generatePom(connector);
    java.nio.file.Path tmpDir = Files.createTempDirectory("syndesis-connector");
    try {
        Files.write(tmpDir.resolve("pom.xml"), pom);
        ArrayList<String> args = new ArrayList<>();
        args.add("mvn");
        args.add("org.apache.maven.plugins:maven-dependency-plugin:3.0.0:build-classpath");
        if (localMavenRepoLocation != null) {
            args.add("-Dmaven.repo.local=" + localMavenRepoLocation);
        }
        ProcessBuilder builder = new ProcessBuilder().command(args)
                .redirectError(ProcessBuilder.Redirect.INHERIT)
                .directory(tmpDir.toFile());
        Map<String, String> environment = builder.environment();
        environment.put("MAVEN_OPTS", "-Xmx64M");
        Process mvn = builder.start();
        try {
            String result = parseClasspath(mvn.getInputStream());
            if (mvn.waitFor() != 0) {
                throw new IOException("Could not get the connector classpath, mvn exit value: " + mvn.exitValue());
            }
            return result;
        } finally {
            mvn.getInputStream().close();
            mvn.getOutputStream().close();
        }
    } finally {
        FileSystemUtils.deleteRecursively(tmpDir.toFile());
    }
}
项目:ARCLib    文件:IngestBpmDelegate.java   
/**
 * Copies folder with SIP contents to workspace
 * @param src path to the folder where the SIP is located
 * @param sipId id of the SIP
 * @throws IOException
 */
private void copySipToWorkspace(String src, String sipId) throws IOException {
    checked(() -> {
        Path folder = Paths.get(workspace);
        if (!exists(folder)) {
            createDirectories(folder);
        }

        FileSystemUtils.copyRecursively(new File(src), new File(workspace, sipId));
    });
}
项目:ARCLib    文件:IngestBpmDelegate.java   
/**
 * From the workspace folder deletes file with the provided id
 *
 * @param sipId id of the file to delete
 */
private void delSipFromWorkspace(String sipId) throws IOException {
    Path directory = Paths.get(workspace, sipId);

    if (exists(directory)) {
        FileSystemUtils.deleteRecursively(new File(directory.toAbsolutePath().toString()));
    }
}
项目:amanda    文件:FileSystemStorageService.java   
@Override
public void delete(String[] paths) {
    Assert.notEmpty(paths, "Paths must not be empty");
    for (String path : paths) {
        LOGGER.info("delete path: " + rootLocation.resolve(path).toAbsolutePath());
        FileSystemUtils.deleteRecursively(rootLocation.resolve(path).toFile());
    }
}