Java 类net.minecraft.util.org.apache.commons.io.FileUtils 实例源码

项目:TatsuCraftMod    文件:TFM_Flatlands.java   
public static void wipeFlatlandsIfFlagged()
{
    boolean doFlatlandsWipe = false;
    try
    {
        doFlatlandsWipe = TFM_Util.getSavedFlag("do_wipe_flatlands");
    }
    catch (Exception ex)
    {
    }

    if (doFlatlandsWipe)
    {
        if (Bukkit.getServer().getWorld("flatlands") == null)
        {
            TFM_Log.info("Wiping flatlands.");
            TFM_Util.setSavedFlag("do_wipe_flatlands", false);
            FileUtils.deleteQuietly(new File("./flatlands"));
        }
        else
        {
            TFM_Log.severe("Can't wipe flatlands, it is already loaded.");
        }
    }
}
项目:TatsuCraftMod    文件:TFM_Config.java   
private static void copyDefaultConfig(File targetFile)
{
    if (targetFile.exists())
    {
        return;
    }

    TFM_Log.info("Installing default configuration file template: " + targetFile.getPath());

    try
    {
        InputStream defaultConfig = getDefaultConfig();
        FileUtils.copyInputStreamToFile(defaultConfig, targetFile);
        defaultConfig.close();
    }
    catch (IOException ex)
    {
        TFM_Log.severe(ex);
    }
}
项目:TatsuCraftMod    文件:TFM_Util.java   
public static void createDefaultConfiguration(final String configFileName)
{
    final File targetFile = new File(TotalFreedomMod.plugin.getDataFolder(), configFileName);

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

    TFM_Log.info("Installing default configuration file template: " + targetFile.getPath());

    try
    {
        final InputStream configFileStream = TotalFreedomMod.plugin.getResource(configFileName);
        FileUtils.copyInputStreamToFile(configFileStream, targetFile);
        configFileStream.close();
    }
    catch (IOException ex)
    {
        TFM_Log.severe(ex);
    }
}
项目:NeoHG    文件:Config.java   
public static void loadConfig() {
    Main.getPlugin().saveDefaultConfig();
    if (!new File(Main.getPlugin().getDataFolder() + "/translations").exists())
        new File(Main.getPlugin().getDataFolder() + "/translations").mkdir();
    if (!new File(Main.getPlugin().getDataFolder() + "/schematics").exists())
        new File(Main.getPlugin().getDataFolder() + "/schematics").mkdir();
    for (int i = 0; i < PATHS.length; i++) {
        File file = new File(PATHS[i]);
        int count = 0;
        if (!file.exists()) {
            count++;
            try {
                file.createNewFile();
                FileUtils.copyInputStreamToFile(Main.getPlugin()
                        .getResource(file.getAbsolutePath()
                                .replace(Main.getPlugin().getDataFolder().getAbsolutePath(), "").substring(1)
                                .replace("\\", "/")),
                        file);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        Main.log("/ Foram criado(s) " + count + " arquivo(s) de configuracao.");
        if (file.getAbsolutePath().contains(".yml"))
            CONFIGURATIONS[i] = YamlConfiguration.loadConfiguration(file);
    }
}
项目:Tweakkit-Server    文件:ServerStatisticManager.java   
public void a() {
    if (this.d.isFile()) {
        try {
            this.a.clear();
            this.a.putAll(this.a(FileUtils.readFileToString(this.d)));
        } catch (IOException ioexception) {
            b.error("Couldn\'t read statistics file " + this.d, ioexception);
        } catch (JsonParseException jsonparseexception) {
            b.error("Couldn\'t parse statistics file " + this.d, jsonparseexception);
        }
    }
}
项目:Tweakkit-Server    文件:ServerStatisticManager.java   
public void b() {
    if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot
    try {
        FileUtils.writeStringToFile(this.d, a(this.a));
    } catch (IOException ioexception) {
        b.error("Couldn\'t save stats", ioexception);
    }
}
项目:TatsuCraftMod    文件:TFM_Util.java   
public static boolean deleteFolder(final File file)
{
    if (file.exists() && file.isDirectory())
    {
        return FileUtils.deleteQuietly(file);
    }
    return false;
}
项目:civcraft    文件:CivSettings.java   
public static void streamResourceToDisk(String filepath) throws IOException {
    URL inputUrl = plugin.getClass().getResource(filepath);
    File dest = new File(plugin.getDataFolder().getPath()+filepath);
    FileUtils.copyURLToFile(inputUrl, dest);
}
项目:TatsuCraftMod    文件:Module_dump.java   
private String body()
{
    StringBuilder responseBody = new StringBuilder();

    String remoteAddress = socket.getInetAddress().getHostAddress();

    String[] args = StringUtils.split(uri, "/");

    Map<String, String> files = getFiles();

    responseBody
            .append(paragraph("URI: " + uri))
            .append(paragraph("args (Length: " + args.length + "): " + StringUtils.join(args, ",")))
            .append(paragraph("Method: " + method.toString()))
            .append(paragraph("Remote Address: " + remoteAddress))
            .append(paragraph("Headers:"))
            .append(list(headers))
            .append(paragraph("Params:"))
            .append(list(params))
            .append(paragraph("Files:"))
            .append(list(files));

    Iterator<Map.Entry<String, String>> it = files.entrySet().iterator();
    while (it.hasNext())
    {
        Map.Entry<String, String> entry = it.next();
        String formName = entry.getKey();
        String tempFileName = entry.getValue();
        String origFileName = params.get(formName);

        File tempFile = new File(tempFileName);
        if (tempFile.exists())
        {
            this.echoFile = tempFile;

            if (origFileName.contains("../"))
            {
                continue;
            }

            String targetFileName = "./public_html/uploads/" + origFileName;

            File targetFile = new File(targetFileName);

            try
            {
                FileUtils.copyFile(tempFile, targetFile);
            }
            catch (IOException ex)
            {
                TFM_Log.severe(ex);
            }
        }
    }

    return responseBody.toString();
}
项目:TatsuCraftMod    文件:Module_schematic.java   
private boolean uploadSchematic() throws SchematicTransferException
{
    Map<String, String> files = getFiles();

    final String tempFileName = files.get(REQUEST_FORM_FILE_ELEMENT_NAME);
    if (tempFileName == null)
    {
        throw new SchematicTransferException("No file transmitted to server.");
    }

    final File tempFile = new File(tempFileName);
    if (!tempFile.exists())
    {
        throw new SchematicTransferException();
    }

    String origFileName = params.get(REQUEST_FORM_FILE_ELEMENT_NAME);
    if (origFileName == null || (origFileName = origFileName.trim()).isEmpty())
    {
        throw new SchematicTransferException("Can't resolve original file name.");
    }

    if (tempFile.length() > FileUtils.ONE_KB * 64L)
    {
        throw new SchematicTransferException("Schematic is too big (64kb max).");
    }

    if (!SCHEMATIC_FILENAME_LC.matcher(origFileName.toLowerCase()).find())
    {
        throw new SchematicTransferException("File name must be alphanumeric, between 1 and 30 characters long (inclusive), and have a \".schematic\" extension.");
    }

    final File targetFile = new File(SCHEMATIC_FOLDER.getPath(), origFileName);
    if (targetFile.exists())
    {
        throw new SchematicTransferException("Schematic already exists on the server.");
    }

    try
    {
        FileUtils.copyFile(tempFile, targetFile);
    }
    catch (IOException ex)
    {
        TFM_Log.severe(ex);
        throw new SchematicTransferException();
    }

    return true;
}