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


Java FileDeleteStrategy类代码示例

本文整理汇总了Java中org.apache.commons.io.FileDeleteStrategy的典型用法代码示例。如果您正苦于以下问题:Java FileDeleteStrategy类的具体用法?Java FileDeleteStrategy怎么用?Java FileDeleteStrategy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: validate

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
@Override
public void validate(String name, String value) throws ParameterException {
    File file = new File(value);
    ParameterException exception = new ParameterException("File " + file.getAbsolutePath() + " does not exist and cannot be created.");
    try {

        if (!file.exists()) {
            boolean canCreate = file.createNewFile();
            if (canCreate) {
                FileDeleteStrategy.FORCE.delete(file);
            } else {
                throw exception;
            }

        }
    } catch (IOException exc) {
        throw exception;
    }

}
 
开发者ID:chenshuiluke,项目名称:jresume,代码行数:21,代码来源:FileLocationValidator.java

示例2: deleteArena

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
/**
 * Deletes the folder of the world
 */
public void deleteArena() {
    if (Bukkit.getServer().unloadWorld(fileName, false)) {
        try {
            FileDeleteStrategy.FORCE.delete(new File(fileName));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:13,代码来源:Arena.java

示例3: prepareEnvironment

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
private void prepareEnvironment() throws IOException {
    if (Files.exists(Paths.get("data"))) {
        FileDeleteStrategy.FORCE.delete(new File("data"));
    }

    Files.createDirectory(Paths.get("data"));
}
 
开发者ID:chenshuiluke,项目名称:jresume,代码行数:8,代码来源:Router.java

示例4: extractResourcesFromJarFile

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
private void extractResourcesFromJarFile() throws Exception {
    String classUrl = Main.class.getResource("Main.class").toString();

    URL url = Main.class.getResource("/resources.zip");
    //System.out.println("JAR Resource Zip URL: " + url.toString());
    InputStream inputStream = url.openStream();


    if (config.serverMode) {
        newResourceZip = config.serverInitialResourceZip;
        newResourceFolder = Paths.get("data", "resources").toFile();
    } else {
        newResourceZip = Paths.get(config.outputDirectory, "webresume-resources.zip").toFile();
        newResourceFolder = Paths.get(config.outputDirectory, config.resourceDirectory).toFile();
    }

    if (!newResourceFolder.exists()) {
        newResourceFolder.mkdirs();
    }

    if (newResourceZip.exists()) {
        FileDeleteStrategy.FORCE.delete(newResourceZip);
    }

    Files.copy(inputStream, newResourceZip.toPath());

    ZipFile zipFile = new ZipFile(newResourceZip);
    zipFile.extractAll(newResourceFolder.getAbsolutePath());
}
 
开发者ID:chenshuiluke,项目名称:jresume,代码行数:30,代码来源:ResumeGenerator.java

示例5: execute

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
@Override
public boolean execute(String[] args)
{
    instance.getLogger().info("Checking servers...");
    File[] files = this.instance.getServerFolder().listFiles();
    for(File file : files)
    {
        String name = file.getName();

        MinecraftServerC serverC = instance.getServerManager().getServerByName(name);
        if(serverC == null)
        {
            instance.getConnectionManager().sendPacket(new MinecraftServerUpdatePacket(instance, name, MinecraftServerUpdatePacket.UType.END));
            instance.getLogger().info("Server: " + name + " not found. Sending shutdown to hydro.");
            try{
                FileDeleteStrategy.FORCE.delete(file);
                instance.getLogger().info("Deleted folder!");
            }catch(Exception e)
            {
                e.printStackTrace();
                instance.getLogger().info("Can't delete folder!");
            }
        }
    }
    instance.getLogger().info("Check done !");
    return true;
}
 
开发者ID:SamaGames,项目名称:Hydroangeas,代码行数:28,代码来源:CleanupCommand.java

示例6: MinecraftServerC

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
public MinecraftServerC(HydroangeasClient instance,
                        MinecraftServerSyncPacket serverInfos,
                        int port)
{
    super(serverInfos.getMinecraftUUID(),
            serverInfos.getGame(),
            serverInfos.getMap(),
            serverInfos.getMinSlot(),
            serverInfos.getMaxSlot(),
            serverInfos.getOptions(),
            serverInfos.getStartupOptions()
            );
    this.instance = instance;

    this.coupaingServer = serverInfos.isCoupaingServer();

    this.hubID = serverInfos.getHubID();

    this.templateID = serverInfos.getTemplateID();

    this.timeToLive = serverInfos.getTimeToLive();

    this.serverFolder = new File(this.instance.getServerFolder(), serverInfos.getServerName());
    try
    {
        FileDeleteStrategy.FORCE.delete(serverFolder);
        FileUtils.forceDeleteOnExit(serverFolder);
    } catch (IOException e)
    {
        getLogger().warning(serverFolder + " will not be able to be deleted during JVM shutdown!");
    }
    this.port = port;

    this.weight = serverInfos.getWeight();
}
 
开发者ID:SamaGames,项目名称:Hydroangeas,代码行数:36,代码来源:MinecraftServerC.java

示例7: startServer

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
public boolean startServer()
{
    try
    {
        JsonObject startupOptionsObj = startupOptions.getAsJsonObject();
        String maxRAM = startupOptionsObj.get("maxRAM").getAsString();

        container = new DockerContainer(
                getServerName(),
                serverFolder,
                port,
                new String[]{"/usr/bin/java",
                        //"-Duser.dir " + serverFolder.getAbsolutePath(),
                        "-Xmx" + maxRAM,
                        "-Xms" + startupOptionsObj.get("minRAM").getAsString(),
                        "-Xmn" + startupOptionsObj.get("edenRAM").getAsString(),
                        "-XX:+UseG1GC",
                        "-XX:+UnlockExperimentalVMOptions",
                        "-XX:MaxGCPauseMillis=50",
                        "-XX:+DisableExplicitGC",
                        "-XX:G1HeapRegionSize=4M",
                        "-XX:TargetSurvivorRatio=90",
                        "-XX:G1NewSizePercent=50",
                        "-XX:G1MaxNewSizePercent=80",
                        "-XX:InitiatingHeapOccupancyPercent=10",
                        "-XX:G1MixedGCLiveThresholdPercent=50",
                        "-XX:+AggressiveOpts",
                        "-XX:+UseLargePagesInMetaspace",
                        "-Djava.net.preferIPv4Stack=true",
                        "-Dcom.sun.management.jmxremote",
                        "-Dcom.sun.management.jmxremote.port=" + (getPort()+1),
                        "-Dcom.sun.management.jmxremote.local.only=false",
                        "-Dcom.sun.management.jmxremote.authenticate=false",
                        "-Dcom.sun.management.jmxremote.ssl=false",
                        "-jar", serverFolder.getAbsolutePath()+"/spigot.jar", "nogui"},
                maxRAM
        );
        Hydroangeas.getLogger().info(container.createContainer());

        getLogger().info("Starting server " + getServerName());

        remoteControl = new RemoteControl(this, "blackmesa", (getPort()+1));
    } catch (Exception e)
    {
        this.instance.log(Level.SEVERE, "Can't start the server " + getServerName() + "!");
        e.printStackTrace();
        try
        {
            FileDeleteStrategy.FORCE.delete(serverFolder);
            FileUtils.forceDelete(serverFolder);
        } catch (IOException e1)
        {
        }

        return false;
    }

    return true;
}
 
开发者ID:SamaGames,项目名称:Hydroangeas,代码行数:60,代码来源:MinecraftServerC.java

示例8: stopServer

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
public boolean stopServer()
{
    try
    {
        try{
            if (remoteControl != null)
                remoteControl.disconnect();
        }catch (Exception ignored)
        {

        }

        instance.getServerManager().onServerStop(this);
        Hydroangeas.getInstance().getAsClient().getLogManager().saveLog(getServerName(), getTemplateID());
        container.removeContainer();

    } catch (Exception e)
    {
        this.instance.log(Level.SEVERE, "Can't stop the server " + getServerName() + "!");
        e.printStackTrace();
        return false;
    }finally {
        try
        {
            FileDeleteStrategy.FORCE.delete(serverFolder);
            FileUtils.forceDelete(serverFolder);
        } catch (IOException e1)
        {
        }
    }
    return true;
}
 
开发者ID:SamaGames,项目名称:Hydroangeas,代码行数:33,代码来源:MinecraftServerC.java

示例9: clearProjectBuildDirectory

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
private void clearProjectBuildDirectory(File buildDirectory) throws IOException {
	for(File file : buildDirectory.listFiles()){
		if(file.isDirectory()){
			File directory = file;
			clearProjectBuildDirectory(directory);
			directory.delete();
		} else {
			FileDeleteStrategy.FORCE.delete(file);
		}
	}
}
 
开发者ID:JReFrameworker,项目名称:JReFrameworker,代码行数:12,代码来源:JReFrameworkerProject.java

示例10: createAndTrackTempFile

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
private File createAndTrackTempFile(FormItem item) throws IOException {
    if (tmpPathForRequest == null) {
        if (Files.notExists(tempRepoPath)) {
            Files.createDirectory(tempRepoPath);
        }
        tmpPathForRequest = Files.createTempDirectory(tempRepoPath, "tmp");
    }
    Path path = Paths.get(tmpPathForRequest.toString(), item.getName());
    File file = path.toFile();
    StreamUtil.copy(item.openStream(), new FileOutputStream(file), true);
    fileCleaningTracker.track(file, file);
    fileCleaningTracker.track(tmpPathForRequest.toFile(), file, FileDeleteStrategy.FORCE);
    return file;
}
 
开发者ID:wso2,项目名称:msf4j,代码行数:15,代码来源:HttpResourceModelProcessor.java

示例11: delete

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
/**
    * It deletes the folder whose path is given by the argument folderPath.
    * It deletes each folder forcefully even if it contains files underneath it.
    * 
    *
    * @param folderPath the folder path
    */
public void delete(String folderPath) {
	FileDeleteStrategy file = FileDeleteStrategy.FORCE;
	try {

		file.delete(new File(folderPath));
	} catch (Exception fileDeleteException) {
		logger.severe(StackTrace.asString(fileDeleteException));
	}

}
 
开发者ID:amishwins,项目名称:project-cec-2013,代码行数:18,代码来源:FolderDaoImpl.java

示例12: deleteTemplate

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
@Override
public void deleteTemplate(String fileName) {
	FileDeleteStrategy file = FileDeleteStrategy.FORCE;
	try{
		file.delete(new File( pathToTemplate + fileName.toString() + ".xml")); 
	} catch(IOException fileDeleteException){
		fileDeleteException.printStackTrace();
		throw new RuntimeException("Cannot delete template!");
	}    
}
 
开发者ID:amishwins,项目名称:project-cec-2013,代码行数:11,代码来源:TemplateXMLDao.java

示例13: shutdownFirefoxProfile

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
/**
 * 
 * @param firefoxProfile 
 */
public void shutdownFirefoxProfile(FirefoxProfile firefoxProfile) {
    try {
        if (deleteProfileData) {
            FileDeleteStrategy.FORCE.delete(new File(netExportPathMap.get(firefoxProfile)));
        }
    } catch (IOException ex) {
        Logger.getLogger(this.getClass()).error(ex);
    }
    netExportPathMap.remove(firefoxProfile);
}
 
开发者ID:Tanaguru,项目名称:Tanaguru,代码行数:15,代码来源:ProfileFactory.java

示例14: cleanup

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
public void cleanup()
{
    try
    {
        FileDeleteStrategy.FORCE.delete(config.getDbStorageDirectory());
    }
    catch (IOException e)
    {
        logger.fatal("Unable to clean up db storage directory: " + e.getMessage());
        System.exit(1);
    }
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:13,代码来源:GraphDatabaseBenchmark.java

示例15: tearDown

import org.apache.commons.io.FileDeleteStrategy; //导入依赖的package包/类
@Override
protected void tearDown() throws Exception {
    super.tearDown();
    try {
        store.close();
        environment.close();
    } finally {
        FileDeleteStrategy.FORCE.delete(tempDir);
    }
}
 
开发者ID:we7,项目名称:voldemort,代码行数:11,代码来源:BdbStorageEngineTest.java


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