本文整理了Java中net.sf.okapi.common.Util.normalizeNewlines()
方法的一些代码示例,展示了Util.normalizeNewlines()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.normalizeNewlines()
方法的具体详情如下:
包路径:net.sf.okapi.common.Util
类名称:Util
方法名:normalizeNewlines
[英]Converts all \r\n and \r to linefeed (\n)
[中]将所有\r\n和\r转换为换行符(\n)
代码示例来源:origin: net.sf.okapi/okapi-core
public static String streamAsString(InputStream in, String encoding) {
try (Scanner s = new Scanner(in, encoding)) {
s.useDelimiter("\\A");
String tmp = s.hasNext() ? s.next() : "";
return Util.normalizeNewlines(tmp.toString());
}
}
代码示例来源:origin: net.sf.okapi.filters/okapi-filter-abstractmarkup
public String normalizeHtmlText(String text, boolean insideAttribute, boolean preserveWhitespace) {
// convert all entities to Unicode
String decodedValue = text;
if (!preserveWhitespace) {
decodedValue = collapseWhitespace(decodedValue);
decodedValue = decodedValue.trim();
}
decodedValue = Util.normalizeNewlines(decodedValue);
return decodedValue;
}
代码示例来源:origin: net.sf.okapi.lib/okapi-lib-persistence
/**
* Serialize a given object to a JSON string.
* Object type information is stored in the string.
* @param obj the given object.
* @param prettyPrint true to output the JSON string as multi-line indented text.
* @return a JSON string containing the object type info and serialized object.
*/
public static <T> String toJSON(T obj, boolean prettyPrint) {
JSONBean<T> bean = new JSONBean<T>();
bean.setClassName(ClassUtil.getQualifiedClassName(obj));
try {
if (prettyPrint) {
mapper.enable(SerializationFeature.INDENT_OUTPUT);
}
else {
mapper.disable(SerializationFeature.INDENT_OUTPUT);
}
bean.setContent(obj);
return Util.normalizeNewlines(mapper.writeValueAsString(bean));
} catch (JsonProcessingException e) {
throw new OkapiIOException(e);
}
}
代码示例来源:origin: net.sf.okapi.filters/okapi-filter-yaml
eventBuilder.addToTextUnit(Util.normalizeNewlines(l.line));
内容来源于网络,如有侵权,请联系作者删除!