cn.hutool.core.util.StrUtil.utf8Str()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(471)

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

StrUtil.utf8Str介绍

[英]将对象转为字符串
1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
[中]将对象转为字符串
1、 字节数组和ByteBuffer会被转换为对应字符串的数组 2.对象数组会调用数组。托斯特林方法

代码示例

代码示例来源:origin: looly/hutool

/**
 * 格式化文本,使用 {varName} 占位<br>
 * map = {a: "aValue", b: "bValue"} format("{a} and {b}", map) ---=》 aValue and bValue
 * 
 * @param template 文本模板,被替换的部分用 {key} 表示
 * @param map 参数值对
 * @return 格式化后的文本
 */
public static String format(CharSequence template, Map<?, ?> map) {
  if (null == template) {
    return null;
  }
  if (null == map || map.isEmpty()) {
    return template.toString();
  }
  String template2 = template.toString();
  String value;
  for (Entry<?, ?> entry : map.entrySet()) {
    value = utf8Str(entry.getValue());
    if (null != value) {
      template2 = replace(template2, "{" + entry.getKey() + "}", value);
    }
  }
  return template2;
}

代码示例来源:origin: looly/hutool

/**
 * 格式化文本,使用 {varName} 占位<br>
 * map = {a: "aValue", b: "bValue"} format("{a} and {b}", map) ---=》 aValue and bValue
 * 
 * @param template 文本模板,被替换的部分用 {key} 表示
 * @param map 参数值对
 * @return 格式化后的文本
 */
public static String format(CharSequence template, Map<?, ?> map) {
  if (null == template) {
    return null;
  }
  if (null == map || map.isEmpty()) {
    return template.toString();
  }
  String template2 = template.toString();
  String value;
  for (Entry<?, ?> entry : map.entrySet()) {
    value = utf8Str(entry.getValue());
    if (null != value) {
      template2 = replace(template2, "{" + entry.getKey() + "}", value);
    }
  }
  return template2;
}

代码示例来源:origin: looly/hutool

sbuf.append(StrUtil.utf8Str(argArray[argIndex]));
  handledPosition = delimIndex + 2;
} else {
sbuf.append(StrUtil.utf8Str(argArray[argIndex]));
handledPosition = delimIndex + 2;

代码示例来源:origin: looly/hutool

sbuf.append(StrUtil.utf8Str(argArray[argIndex]));
  handledPosition = delimIndex + 2;
} else {
sbuf.append(StrUtil.utf8Str(argArray[argIndex]));
handledPosition = delimIndex + 2;

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 格式化文本,使用 {varName} 占位<br>
 * map = {a: "aValue", b: "bValue"} format("{a} and {b}", map) ---=》 aValue and bValue
 * 
 * @param template 文本模板,被替换的部分用 {key} 表示
 * @param map 参数值对
 * @return 格式化后的文本
 */
public static String format(CharSequence template, Map<?, ?> map) {
  if (null == template) {
    return null;
  }
  if (null == map || map.isEmpty()) {
    return template.toString();
  }
  String template2 = template.toString();
  String value;
  for (Entry<?, ?> entry : map.entrySet()) {
    value = utf8Str(entry.getValue());
    if (null != value) {
      template2 = replace(template2, "{" + entry.getKey() + "}", value);
    }
  }
  return template2;
}

代码示例来源:origin: cn.hutool/hutool-all

sbuf.append(StrUtil.utf8Str(argArray[argIndex]));
  handledPosition = delimIndex + 2;
} else {
sbuf.append(StrUtil.utf8Str(argArray[argIndex]));
handledPosition = delimIndex + 2;

相关文章

微信公众号

最新文章

更多

StrUtil类方法