org.javalite.common.Util.readResource()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(210)

本文整理了Java中org.javalite.common.Util.readResource()方法的一些代码示例,展示了Util.readResource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.readResource()方法的具体详情如下:
包路径:org.javalite.common.Util
类名称:Util
方法名:readResource

Util.readResource介绍

[英]Reads contents of resource fully into a string. Sets UTF-8 encoding internally.
[中]将资源的内容完全读入字符串。在内部设置UTF-8编码。

代码示例

代码示例来源:origin: javalite/activejdbc

/**
 * @param templatePath path to a template on classpath
 */
public Templator(String templatePath){
  template = readResource(templatePath);
}

代码示例来源:origin: javalite/activejdbc

/**
 * Reads contents of resource fully into a string. Sets UTF-8 encoding internally.
 *
 * @param resourceName resource name.
 * @return entire contents of resource as string.
 */
public static String readResource(String resourceName) {
  return readResource(resourceName, "UTF-8");
}

代码示例来源:origin: javalite/activejdbc

/**
 * This method  is used in one-off operations, where it is OK to load a template every time.
 *
 * Example:
 * <code>
 *     String result = Templator.mergeFromPath(readResource("/message_template.txt", valuesMap));
 * </code>
 *
 * @param templatePath template to merge
 * @param values values to merge into a template
 * @return result of merging
 */
public static String mergeFromPath(String templatePath, Map<String, ?> values) {
  return mergeFromTemplate(readResource(templatePath), values);
}

代码示例来源:origin: com.github.tchoulihan/javalite-common

/**
 * Reads contents of resource fully into a string. Sets UTF-8 encoding internally.
 *
 * @param resourceName resource name.
 * @return entire contents of resource as string.
 */
public static String readResource(String resourceName) {
  return readResource(resourceName, "UTF-8");
}

代码示例来源:origin: org.javalite/javalite-common

/**
 * @param templatePath path to a template on classpath
 */
public Templator(String templatePath){
  template = readResource(templatePath);
}

代码示例来源:origin: org.javalite/javalite-common

/**
 * Reads contents of resource fully into a string. Sets UTF-8 encoding internally.
 *
 * @param resourceName resource name.
 * @return entire contents of resource as string.
 */
public static String readResource(String resourceName) {
  return readResource(resourceName, "UTF-8");
}

代码示例来源:origin: org.javalite/javalite-common

/**
 * This method  is used in one-off operations, where it is OK to load a template every time.
 *
 * Example:
 * <code>
 *     String result = Templator.mergeFromPath(readResource("/message_template.txt", valuesMap));
 * </code>
 *
 * @param templatePath template to merge
 * @param values values to merge into a template
 * @return result of merging
 */
public static String mergeFromPath(String templatePath, Map<String, ?> values) {
  return mergeFromTemplate(readResource(templatePath), values);
}

代码示例来源:origin: javalite/activeweb

String filePath = Files.createTempDirectory("async").toFile().getCanonicalPath();
Async async = new Async(filePath, true, new QueueConfig(QUEUE_NAME));
String loremIpsum = Util.readResource("/lorem-ipsum.txt");
async.start();

代码示例来源:origin: javalite/activeweb

private static void testSendMethod() throws IOException {
    String QUEUE_NAME = "queue1";
    String filePath = Files.createTempDirectory("async").toFile().getCanonicalPath();
    Async async = new Async(filePath, false, new QueueConfig(QUEUE_NAME, new CommandListener(), LISTENER_THREAD_COUNT));
    String loremIpsum = Util.readResource("/lorem-ipsum.txt");
    async.start();
    HelloPerformanceCommand.START = System.currentTimeMillis();
    Runnable r = () -> {
      for(int i = 0; i < MESSAGES_PER_THREAD; i++){
        async.send(QUEUE_NAME, new HelloPerformanceCommand(loremIpsum + i));
        System.out.println("sent....");
      }
    };

    for(int i = 0; i < SENDING_THREAD_COUNT; i++){
      Thread t = new Thread(r);
      t.start();

      try {

        Thread.sleep(100);
      } catch (Exception e) {
        e.printStackTrace();
      }

    }
  }
}

相关文章