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


Java FileUtils.deleteDirectory方法代码示例

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


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

示例1: deleteTestPack

import org.apache.tomcat.util.http.fileupload.FileUtils; //导入方法依赖的package包/类
/**
 * delete a directory and all its contents
 *
 * @param dirToDelete directory to be deleted
 *  @throws java.io.IOException unable to delete the file
 */
private void deleteTestPack(String dirToDelete) throws IOException {
	File workSpaceDir = new File(dirToDelete);
		if (workSpaceDir.exists()) {
			FileUtils.deleteDirectory(workSpaceDir);
		}
}
 
开发者ID:wso2,项目名称:cloud-dev-studio,代码行数:13,代码来源:DeveloperStudioExtension.java

示例2: cleanup

import org.apache.tomcat.util.http.fileupload.FileUtils; //导入方法依赖的package包/类
@AfterTest
public void cleanup() throws Exception {
    FileUtils.deleteDirectory(tmpDir);
    tmpDir.delete();
}
 
开发者ID:christophd,项目名称:citrus-admin,代码行数:6,代码来源:FileBrowserServiceTest.java

示例3: testAdditionalWebInfClassesPaths

import org.apache.tomcat.util.http.fileupload.FileUtils; //导入方法依赖的package包/类
@Test
public void testAdditionalWebInfClassesPaths() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0-virtual-webapp/src/main/webapp");
    // app dir is relative to server home
    StandardContext ctx = (StandardContext) tomcat.addWebapp(null, "/test",
        appDir.getAbsolutePath());
    File tempFile = File.createTempFile("virtualWebInfClasses", null);

    File additionWebInfClasses = new File(tempFile.getAbsolutePath() + ".dir");
    Assert.assertTrue(additionWebInfClasses.mkdirs());
    File targetPackageForAnnotatedClass =
        new File(additionWebInfClasses,
            MyAnnotatedServlet.class.getPackage().getName().replace('.', '/'));
    Assert.assertTrue(targetPackageForAnnotatedClass.mkdirs());
    InputStream annotatedServletClassInputStream =
        this.getClass().getResourceAsStream(
            MyAnnotatedServlet.class.getSimpleName() + ".class");
    FileOutputStream annotatedServletClassOutputStream =
        new FileOutputStream(new File(targetPackageForAnnotatedClass,
            MyAnnotatedServlet.class.getSimpleName() + ".class"));
    IOUtils.copy(annotatedServletClassInputStream, annotatedServletClassOutputStream);
    annotatedServletClassInputStream.close();
    annotatedServletClassOutputStream.close();

    VirtualWebappLoader loader = new VirtualWebappLoader(ctx.getParentClassLoader());
    loader.setVirtualClasspath("test/webapp-3.0-virtual-webapp/target/classes;" + //
        "test/webapp-3.0-virtual-library/target/classes;" + //
        additionWebInfClasses.getAbsolutePath());
    ctx.setLoader(loader);

    tomcat.start();
    // first test that without the setting on StandardContext the annotated
    // servlet is not detected
    assertPageContains("/test/annotatedServlet", MyAnnotatedServlet.MESSAGE, 404);

    tomcat.stop();

    // then test that if we configure StandardContext with the additional
    // path, the servlet is detected
    // ctx.setAdditionalVirtualWebInfClasses(additionWebInfClasses.getAbsolutePath());
    VirtualDirContext resources = new VirtualDirContext();
    resources.setExtraResourcePaths("/WEB-INF/classes=" + additionWebInfClasses);
    ctx.setResources(resources);

    tomcat.start();
    assertPageContains("/test/annotatedServlet", MyAnnotatedServlet.MESSAGE);
    tomcat.stop();
    FileUtils.deleteDirectory(additionWebInfClasses);
    tempFile.delete();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:53,代码来源:TestVirtualContext.java

示例4: pushAppBits

import org.apache.tomcat.util.http.fileupload.FileUtils; //导入方法依赖的package包/类
private void pushAppBits(AbstractBuild build, BuildListener listener, DeploymentInfo deploymentInfo,
                         CloudFoundryClient client)
        throws IOException, InterruptedException, ZipException {
    FilePath appPath = new FilePath(build.getWorkspace(), deploymentInfo.getAppPath());

    if (appPath.getChannel() != Jenkins.MasterComputer.localChannel) {
        if (appPath.isDirectory()) {
            // The build is distributed, and a directory
            // We need to make a copy of the target directory on the master
            File tempAppFile = File.createTempFile("appFile", null); // This is on the master
            OutputStream outputStream = new FileOutputStream(tempAppFile);
            appPath.zip(outputStream);

            // We now have a zip file on the master, extract it into a directory
            ZipFile appZipFile = new ZipFile(tempAppFile);
            File tempOutputDirectory = new File(tempAppFile.getAbsolutePath().split("\\.")[0]);
            appZipFile.extractAll(tempOutputDirectory.getAbsolutePath());
            // appPath.zip() creates a top level directory that we want to remove
            File[] listFiles = tempOutputDirectory.listFiles();
            if (listFiles != null && listFiles.length == 1) {
                tempOutputDirectory = listFiles[0];
            } else {
                // This should never happen because appPath.zip() always makes a directory
                throw new IllegalStateException("Unzipped output directory was empty.");
            }
            // We can now use tempOutputDirectory which is a copy of the target directory but on master
            client.uploadApplication(deploymentInfo.getAppName(), tempOutputDirectory);
            // Delete temporary files
            boolean deleted = tempAppFile.delete();
            try {
                FileUtils.deleteDirectory(tempOutputDirectory);
            } catch (IOException e) {
                deleted = false;
            }
            if (!deleted) {
                listener.getLogger().println("WARNING: Temporary files were not deleted successfully.");
            }

        } else {
            // If the target path is a single file, we can just use an InputStream
            // The CF client will make a temp file on the master from the InputStream
            client.uploadApplication(deploymentInfo.getAppName(), appPath.getName(), appPath.read());

        }
    } else {
        // If the build is not distributed, we can convert the FilePath to a File without problems
        File targetFile = new File(appPath.toURI());
        client.uploadApplication(deploymentInfo.getAppName(), targetFile);
    }
}
 
开发者ID:hpcloud,项目名称:cloudfoundry-jenkins,代码行数:51,代码来源:CloudFoundryPushPublisher.java

示例5: tearDownClass

import org.apache.tomcat.util.http.fileupload.FileUtils; //导入方法依赖的package包/类
@AfterClass
public static void tearDownClass() throws Exception {

    FileUtils.deleteDirectory(new File(WEBAPP_DOC_BASE));

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:7,代码来源:TestWebappClassLoaderWeaving.java


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