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

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

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

FileUtil.readString介绍

暂无

代码示例

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

public static String readString(File source) throws IOException {
  return readString(source, fileUtilParams.encoding);
}

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

public static String readString(String source) throws IOException {
  return readString(file(source), fileUtilParams.encoding);
}

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

public static String readString(String source, String encoding) throws IOException {
  return readString(file(source), encoding);
}

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

/**
 * @see #readString(File, String)
 */
public static String readString(final String source, final String encoding) throws IOException {
  return readString(file(source), encoding);
}

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

/**
 * Loads properties from the file in provided encoding.
 */
public Props load(final File file, final String encoding) throws IOException {
  parse(FileUtil.readString(file, encoding));
  return this;
}

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

/**
 * @see #readString(String, String)
 */
public static String readString(final String source) throws IOException {
  return readString(source, encoding());
}

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

/**
 * @see #readString(File, String)
 */
public static String readString(final File source) throws IOException {
  return readString(source, encoding());
}

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

private String readFile(String fileName) {
  try {
    return FileUtil.readString(new File(testDataRoot, fileName));
  } catch (IOException ignore) {
    return null;
  }
}

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

/**
 * Reads test file and returns its content optionally stripped.
 */
protected String read(String filename, boolean strip) throws IOException {
  String data = FileUtil.readString(new File(testDataRoot, filename));
  if (strip) {
    data = strip(data);
  }
  return data;
}

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

@Test
void testCleanHtml() throws IOException {
  File ff = new File(testAdapterRoot, "clean.html");
  LagartoParser lagartoParser = new LagartoParser(FileUtil.readString(ff));
  StringBuilder out = new StringBuilder();
  TagWriter tagWriter = new TagWriter(out);
  StripHtmlTagAdapter stripHtmlTagAdapter = new StripHtmlTagAdapter(tagWriter);
  lagartoParser.parse(stripHtmlTagAdapter);
  ff = new File(testAdapterRoot, "clean-out.html");
  assertEquals(FileUtil.readString(ff), out.toString());
}

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

private NodeSelector createNodeFilter() throws IOException {
    File file = new File(testDataRoot, "one.html");
    String html = FileUtil.readString(file);
    return new NodeSelector(new LagartoDOMBuilder().parse(html));
  }
}

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

@Test
void testGroupOfSelectors() throws IOException {
  File file = new File(testDataRoot, "one.html");
  String htmlContent = FileUtil.readString(file);
  Document document = new LagartoDOMBuilder().parse(htmlContent);
  List<Node> nodes = new NodeSelector(document).select("em, b, b");
  assertEquals(9, nodes.size());
  assertTrue(document.check());
}

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

@Test
void testClassWithTabs() throws IOException {
  File file = new File(testDataRoot, "class-tabs.html");
  String htmlContent = FileUtil.readString(file);
  Document document = new LagartoDOMBuilder().parse(htmlContent);
  List<Node> nodes = new NodeSelector(document).select(".hey");
  assertEquals(1, nodes.size());
  Node n = nodes.get(0);
  assertEquals("div", n.getNodeName());
  assertEquals("jodd", n.getAttribute("id"));
}

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

@Test
void testPortletUtils() throws IOException {
  File file = new File(testDataRoot, "PortletUtils.html");
  String content = FileUtil.readString(file);
  Jerry.JerryParser jerryParser = new Jerry.JerryParser();
  //jerryParser.getDOMBuilder().setCalculatePosition(true);
  Jerry doc = jerryParser.parse(content);
  // parse
  doc.$("a").each(($this, index) -> {
    assertEquals("<a name=\"navbar_top\"><!-- --></a>", $this.get()[0].getHtml());
    return false;
  });
}

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

@Test
void testAbstractFormController() throws IOException {
  File file = new File(testDataRoot, "AbstractFormController.html");
  String content = FileUtil.readString(file);
  Jerry.JerryParser jerryParser = new Jerry.JerryParser();
  //jerryParser.getDOMBuilder().setCalculatePosition(true);
  Jerry doc = jerryParser.parse(content);
  // parse
  doc.$("a").each(($this, index) -> {
    assertEquals("<a name=\"navbar_top\"><!-- --></a>", $this.get()[0].getHtml());
    return false;
  });
}

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

@Test
void testIssue23_0() throws IOException {
  File file = new File(testDataRoot, "index-4-v0.html");
  LagartoDOMBuilder lagartoDOMBuilder = new LagartoDOMBuilder();
  lagartoDOMBuilder.getConfig().setCalculatePosition(true);
  lagartoDOMBuilder.getConfig().setCollectErrors(true);
  Document doc = lagartoDOMBuilder.parse(FileUtil.readString(file));
  assertTrue(doc.check());
  assertEquals(1, doc.getErrors().size());
}

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

@Test
void testIssue23_1() throws IOException {
  File file = new File(testDataRoot, "index-4-v1.html");
  LagartoDOMBuilder lagartoDOMBuilder = new LagartoDOMBuilder();
  lagartoDOMBuilder.getConfig().setCalculatePosition(true);
  lagartoDOMBuilder.getConfig().setCollectErrors(true);
  Document doc = lagartoDOMBuilder.parse(FileUtil.readString(file));
  assertTrue(doc.check());
  assertEquals(1, doc.getErrors().size());
}

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

@Test
void testUpheaWebXml() throws IOException {
  File file = new File(testDataRoot, "uphea-web.xml");
  String xmlContent = FileUtil.readString(file);
  LagartoDOMBuilder lagartoDOMBuilder = new LagartoDOMBuilder();
  lagartoDOMBuilder.enableXmlMode();
  Document doc = lagartoDOMBuilder.parse(xmlContent);
  xmlContent = StringUtil.removeChars(xmlContent, "\n\r\t");
  assertEquals(xmlContent, doc.getHtml());
  assertTrue(doc.check());
}

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

@Test
  void testXmlAndSingleQuotes() throws IOException {
    File file = new File(testDataRoot, "people2.xml");
    String xmlContent = FileUtil.readString(file);

    LagartoDOMBuilder lagartoDOMBuilder = new LagartoDOMBuilder();
    lagartoDOMBuilder.enableXmlMode();

    Document xml = lagartoDOMBuilder.parse(xmlContent);

    XmlDeclaration xmlDeclaration = (XmlDeclaration) xml.getChild(0);

    assertEquals("1.0", xmlDeclaration.getVersion());
    assertEquals("UTF-8", xmlDeclaration.getEncoding());
  }
}

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

@Test
void testPreserveCC() throws IOException {
  File file = new File(testDataRoot, "preserve-cc.html");
  String expectedResult = FileUtil.readString(file);
  Jerry.JerryParser jerryParser = new Jerry.JerryParser();
  ((LagartoDOMBuilder) jerryParser.getDOMBuilder()).enableHtmlMode();
  ((LagartoDOMBuilder) jerryParser.getDOMBuilder()).getConfig().setEnableConditionalComments(false);
  Jerry jerry = jerryParser.parse(expectedResult);
  String result = jerry.html();
  assertEquals(expectedResult, result);
}

相关文章