jodd.io.FileUtil.readUTFString()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(273)

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

FileUtil.readUTFString介绍

[英]Detects optional BOM and reads UTF string from a file. If BOM is missing, UTF-8 is assumed.
[中]检测可选BOM表并从文件中读取UTF字符串。如果缺少BOM,则假定为UTF-8。

代码示例

代码示例来源:origin: redisson/redisson

public static String readUTFString(String fileName) throws IOException {
  return readUTFString(file(fileName));
}

代码示例来源:origin: oblac/jodd

/**
 * @see #readUTFString(File)
 */
public static String readUTFString(final String fileName) throws IOException {
  return readUTFString(file(fileName));
}

代码示例来源:origin: oblac/jodd

@Test
void testUTFReads() throws IOException {
  String content = FileUtil.readUTFString(new File(utfdataRoot, "utf-8.txt"));
  content = content.replace("\r\n", "\n");
  String content8 = FileUtil.readString(new File(utfdataRoot, "utf-8.txt"), "UTF-8");
  content8 = content8.replace("\r\n", "\n");
  assertEquals(content, content8);
  String content1 = FileUtil.readUTFString(new File(utfdataRoot, "utf-16be.txt"));
  content1 = content1.replace("\r\n", "\n");
  assertEquals(content, content1);
  String content16 = FileUtil.readString(new File(utfdataRoot, "utf-16be.txt"), "UTF-16BE");
  content16 = content16.replace("\r\n", "\n");
  assertEquals(content, content16);
  String content162 = FileUtil.readString(new File(utfdataRoot, "utf-16be.txt"), "UTF-16");
  content162 = content162.replace("\r\n", "\n");
  assertEquals(content, content162);
  String content2 = FileUtil.readUTFString(new File(utfdataRoot, "utf-16le.txt"));
  content2 = content2.replace("\r\n", "\n");
  assertEquals(content, content2);
  String content163 = FileUtil.readString(new File(utfdataRoot, "utf-16le.txt"), "UTF-16LE");
  content163 = content163.replace("\r\n", "\n");
  assertEquals(content, content163);
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * @see #readUTFString(File)
 */
public static String readUTFString(final String fileName) throws IOException {
  return readUTFString(file(fileName));
}

代码示例来源:origin: com.gitee.morilys.jsmile/jsmile-kit

/**
 *  读取resources下的文件为json字符串
 * @param fileName 要读取的文件名
 * @return 返回json字符串
 * @since  1.0
 */
public static String readResourcesToJson(String fileName) {
  String res=null;
  try {
    res=FileUtil.readUTFString(readResourcesFile(fileName));
  } catch (IOException e) {
    logger.error("读取json文件【"+fileName+"】发生异常!");
    e.printStackTrace();
  }
  return res;
}

相关文章