MCPcopy Create free account
hub / github.com/antlr/codebuff / trimOneTrailingNewline

Method trimOneTrailingNewline

output/java/1.4.17/Misc.java:89–93  ·  view source on GitHub ↗

Strip a single newline character from the end of s.

(String s)

Source from the content-addressed store, hash-verified

87 /** Strip a single newline character from the end of {@code s}. */
88
89 public static String trimOneTrailingNewline(String s) {
90 if ( s.endsWith("\r\n") ) s = s.substring(0, s.length()-2);
91 else if ( s.endsWith("\n") ) s = s.substring(0, s.length()-1);
92 return s;
93 }
94
95 /** Given, say, {@code file:/tmp/test.jar!/org/foo/templates/main.stg}
96 * convert to {@code file:/tmp/test.jar!/org/foo/templates}

Callers 2

defineTemplateMethod · 0.95
defineRegionMethod · 0.95

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected