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


Java Utils类代码示例

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


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

示例1: loadSampleResourceUrls

import ensemble.util.Utils; //导入依赖的package包/类
private static void loadSampleResourceUrls(File destDir, String urlToSampleJavaFile, String[] resourceUrlArray) {
    //get dir from urlToSampleJavaFile
    String sampleJavaFileDir = urlToSampleJavaFile.substring(0,
            urlToSampleJavaFile.lastIndexOf('/') + 1); //include the last forward slash
    List<String> resourceUrlList = Arrays.asList(resourceUrlArray);
    //create resource files for each of the resources we use
    if (!resourceUrlList.isEmpty()) {
        for (String oneResourceUrl : resourceUrlList) {
            String sampleResourceName = oneResourceUrl.substring(
                    oneResourceUrl.lastIndexOf('/') + 1,
                    oneResourceUrl.length());
            try {
                URL resourceUrl = new URL(sampleJavaFileDir + sampleResourceName);
                Utils.copyFile(resourceUrl, destDir.getPath() + "/" + sampleResourceName);
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
        }
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:SampleProjectBuilder.java

示例2: loadCode

import ensemble.util.Utils; //导入依赖的package包/类
private void loadCode() {
    // load syntax highlighter
    if (shCoreJs == null) shCoreJs = Utils.loadFile(Ensemble2.class.getResource("syntaxhighlighter/shCore.js")) +";";
    if (shBrushJScript == null) shBrushJScript = Utils.loadFile(Ensemble2.class.getResource("syntaxhighlighter/shBrushJava.js"));
    if (shCoreDefaultCss == null) shCoreDefaultCss =
            Utils.loadFile(Ensemble2.class.getResource("syntaxhighlighter/shCoreDefault.css")).replaceAll("!important","");
    // load and convert source
    String source = SampleProjectBuilder.loadAndConvertSampleCode(sampleInfo.getSourceFileUrl());
    // store raw code
    rawCode = source;
    // escape < & >
    source = source.replaceAll("&","&amp;");
    source = source.replaceAll("<","&lt;");
    source = source.replaceAll(">","&gt;");
    source = source.replaceAll("\"","&quot;");
    source = source.replaceAll("\'","&apos;");
    // create content
    StringBuilder html = new StringBuilder();
    html.append("<html>\n");
    html.append("    <head>\n");
    html.append("    <script type=\"text/javascript\">\n");
    html.append(shCoreJs);
    html.append('\n');
    html.append(shBrushJScript);
    html.append("    </script>\n");
    html.append("    <style>\n");
    html.append(shCoreDefaultCss);
    html.append('\n');
    html.append("        .syntaxhighlighter {\n");
    html.append("			overflow: visible;\n");
    if (Utils.isMac()) {
        html.append("			font: 12px Ayuthaya !important; line-height: 150% !important; \n");
        html.append("		}\n");
        html.append("		code { font: 12px Ayuthaya !important; line-height: 150% !important; } \n");
    } else {
        html.append("			font: 12px monospace !important; line-height: 150% !important; \n");
        html.append("		}\n");
        html.append("		code { font: 12px monospace !important; line-height: 150% !important; } \n");
    }
    html.append("		.syntaxhighlighter .preprocessor { color: #060 !important; }\n");
    html.append("		.syntaxhighlighter .comments, .syntaxhighlighter .comments a  { color: #009300 !important; }\n");
    html.append("		.syntaxhighlighter .string  { color: #555 !important; }\n");
    html.append("		.syntaxhighlighter .value  { color: blue !important; }\n");
    html.append("		.syntaxhighlighter .keyword  { color: #000080 !important; }\n");
    html.append("    </style>\n");
    html.append("    </head>\n");
    html.append("<body>\n");
    html.append("    <pre class=\"brush: java;gutter: false;toolbar: false;\">\n");
    html.append(source);
    html.append('\n');
    html.append(
            "    </pre>\n" +
                    "    <script type=\"text/javascript\"> SyntaxHighlighter.all(); </script>\n" +
                    "</body>\n" +
                    "</html>\n");
    htmlCode = html.toString();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:58,代码来源:SamplePage.java


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