net.sf.okapi.common.Util.normalizeNewlines()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(227)

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

Util.normalizeNewlines介绍

[英]Converts all \r\n and \r to linefeed (\n)
[中]将所有\r\n和\r转换为换行符(\n)

代码示例

代码示例来源:origin: net.sf.okapi/okapi-core

  1. public static String streamAsString(InputStream in, String encoding) {
  2. try (Scanner s = new Scanner(in, encoding)) {
  3. s.useDelimiter("\\A");
  4. String tmp = s.hasNext() ? s.next() : "";
  5. return Util.normalizeNewlines(tmp.toString());
  6. }
  7. }

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-abstractmarkup

  1. public String normalizeHtmlText(String text, boolean insideAttribute, boolean preserveWhitespace) {
  2. // convert all entities to Unicode
  3. String decodedValue = text;
  4. if (!preserveWhitespace) {
  5. decodedValue = collapseWhitespace(decodedValue);
  6. decodedValue = decodedValue.trim();
  7. }
  8. decodedValue = Util.normalizeNewlines(decodedValue);
  9. return decodedValue;
  10. }

代码示例来源:origin: net.sf.okapi.lib/okapi-lib-persistence

  1. /**
  2. * Serialize a given object to a JSON string.
  3. * Object type information is stored in the string.
  4. * @param obj the given object.
  5. * @param prettyPrint true to output the JSON string as multi-line indented text.
  6. * @return a JSON string containing the object type info and serialized object.
  7. */
  8. public static <T> String toJSON(T obj, boolean prettyPrint) {
  9. JSONBean<T> bean = new JSONBean<T>();
  10. bean.setClassName(ClassUtil.getQualifiedClassName(obj));
  11. try {
  12. if (prettyPrint) {
  13. mapper.enable(SerializationFeature.INDENT_OUTPUT);
  14. }
  15. else {
  16. mapper.disable(SerializationFeature.INDENT_OUTPUT);
  17. }
  18. bean.setContent(obj);
  19. return Util.normalizeNewlines(mapper.writeValueAsString(bean));
  20. } catch (JsonProcessingException e) {
  21. throw new OkapiIOException(e);
  22. }
  23. }

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-yaml

  1. eventBuilder.addToTextUnit(Util.normalizeNewlines(l.line));

相关文章