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


Java Utils.readFile方法代码示例

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


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

示例1: getPluginDescription

import cn.nukkit.utils.Utils; //导入方法依赖的package包/类
@Override
public PluginDescription getPluginDescription(File file) {
    try (JarFile jar = new JarFile(file)) {
        JarEntry entry = jar.getJarEntry("nukkit.yml");
        if (entry == null) {
            entry = jar.getJarEntry("plugin.yml");
            if (entry == null) {
                return null;
            }
        }
        try (InputStream stream = jar.getInputStream(entry)) {
            return new PluginDescription(Utils.readFile(stream));
        }
    } catch (IOException e) {
        return null;
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:18,代码来源:JavaPluginLoader.java

示例2: getPluginDescription

import cn.nukkit.utils.Utils; //导入方法依赖的package包/类
@Override
public PluginDescription getPluginDescription(File file) {
    try {
        JarFile jar = new JarFile(file);
        JarEntry entry = jar.getJarEntry("nukkit.yml");
        if (entry == null) {
            entry = jar.getJarEntry("plugin.yml");
            if (entry == null) {
                return null;
            }
        }
        InputStream stream = jar.getInputStream(entry);
        return new PluginDescription(Utils.readFile(stream));
    } catch (IOException e) {
        return null;
    }
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:18,代码来源:JavaPluginLoader.java

示例3: loadLang

import cn.nukkit.utils.Utils; //导入方法依赖的package包/类
protected Map<String, String> loadLang(String path) {
    try {
        String content = Utils.readFile(path);
        Map<String, String> d = new HashMap<>();
        for (String line : content.split("\n")) {
            line = line.trim();
            if (line.equals("") || line.charAt(0) == '#') {
                continue;
            }
            String[] t = line.split("=");
            if (t.length < 2) {
                continue;
            }
            String key = t[0];
            String value = "";
            for (int i = 1; i < t.length - 1; i++) {
                value += t[i] + "=";
            }
            value += t[t.length - 1];
            if (value.equals("")) {
                continue;
            }
            d.put(key, value);
        }
        return d;
    } catch (IOException e) {
        Server.getInstance().getLogger().logException(e);
        return null;
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:31,代码来源:BaseLang.java

示例4: importLanguages

import cn.nukkit.utils.Utils; //导入方法依赖的package包/类
private void importLanguages(){
	this.language = new HashMap<>();
	
	for(String lang : langList){
		InputStream is = this.getResource("lang_" + lang + ".json");
		try {
			JSONObject obj = new JSONObject(Utils.readFile(is));
			this.language.put(lang, obj);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:EconomyS,项目名称:EconomyAPI,代码行数:14,代码来源:EconomyAPI.java

示例5: loadLang

import cn.nukkit.utils.Utils; //导入方法依赖的package包/类
private Map<String, String> loadLang(String path) {
    try {
        String content = Utils.readFile(path);
        Map<String, String> d = new HashMap<>();
        for (String line : content.split("\n")) {
            line = line.trim();
            if (line.equals("") || line.charAt(0) == '#') {
                continue;
            }
            String[] t = line.split("=");
            if (t.length < 2) {
                continue;
            }
            String key = t[0];
            String value = "";
            for (int i = 1; i < t.length - 1; i++) {
                value += t[i] + "=";
            }
            value += t[t.length - 1];
            if (value.equals("")) {
                continue;
            }
            d.put(key, value);
        }
        return d;
    } catch (IOException e) {
        Server.getInstance().getLogger().logException(e);
        return null;
    }
}
 
开发者ID:yescallop,项目名称:EssentialsNK,代码行数:31,代码来源:BaseLang.java

示例6: generate

import cn.nukkit.utils.Utils; //导入方法依赖的package包/类
private String generate() throws IOException {
    File reports = new File(Nukkit.DATA_PATH, "logs/bug_reports");
    if (!reports.isDirectory()) {
        reports.mkdirs();
    }

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmSS");
    String date = simpleDateFormat.format(new Date());

    SystemInfo systemInfo = new SystemInfo();
    long totalDiskSize = 0;
    StringBuilder model = new StringBuilder();
    for (HWDiskStore hwDiskStore : systemInfo.getHardware().getDiskStores()) {
        totalDiskSize += hwDiskStore.getSize();
        if (!model.toString().contains(hwDiskStore.getModel())) {
            model.append(hwDiskStore.getModel()).append(" ");
        }
    }

    StringWriter stringWriter = new StringWriter();
    throwable.printStackTrace(new PrintWriter(stringWriter));


    File mdReport = new File(reports, date + "_" + throwable.getClass().getSimpleName() + ".md");
    mdReport.createNewFile();
    String content = Utils.readFile(this.getClass().getClassLoader().getResourceAsStream("report_template.md"));

    Properties properties = getGitRepositoryState();
    System.out.println(properties.getProperty("git.commit.id.abbrev"));
    String abbrev = properties.getProperty("git.commit.id.abbrev");

    content = content.replace("${NUKKIT_VERSION}", Nukkit.VERSION);
    content = content.replace("${GIT_COMMIT_ABBREV}", abbrev);
    content = content.replace("${JAVA_VERSION}", System.getProperty("java.vm.name") + " (" + System.getProperty("java.runtime.version") + ")");
    content = content.replace("${HOSTOS}", systemInfo.getOperatingSystem().getFamily() + " [" + systemInfo.getOperatingSystem().getVersion().getVersion() + "]");
    content = content.replace("${MEMORY}", getCount(systemInfo.getHardware().getMemory().getTotal(), true));
    content = content.replace("${STORAGE_SIZE}", getCount(totalDiskSize, true));
    content = content.replace("${CPU_TYPE}", systemInfo.getHardware().getProcessor().getName());
    content = content.replace("${PHYSICAL_CORE}", String.valueOf(systemInfo.getHardware().getProcessor().getPhysicalProcessorCount()));
    content = content.replace("${LOGICAL_CORE}", String.valueOf(systemInfo.getHardware().getProcessor().getLogicalProcessorCount()));
    content = content.replace("${STACKTRACE}", stringWriter.toString());
    content = content.replace("${PLUGIN_ERROR}", String.valueOf(!throwable.getStackTrace()[0].getClassName().startsWith("cn.nukkit")).toUpperCase());
    content = content.replace("${STORAGE_TYPE}", model.toString());

    Utils.writeFile(mdReport, content);

    return mdReport.getAbsolutePath();
}
 
开发者ID:Nukkit,项目名称:Nukkit,代码行数:49,代码来源:BugReportGenerator.java


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