import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import java.util.StringJoiner;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
return y.toString();
}
+ public static String removeLine(String x, int lineNumber) {
+ if (null == x) {
+ throw new IllegalArgumentException("Invalid 'x': null.");
+ }
+ //
+ String[] xLines = x.split(System.getProperty("line.separator"));
+ //
+ if ((0 > lineNumber) || (xLines.length - 1 < lineNumber)) {
+ throw new IllegalArgumentException(String.format("Invalid 'lineNumber': %s.", lineNumber));
+ }
+ //
+ StringJoiner stringJoiner = new StringJoiner(System.getProperty("line.separator"));
+ for (int l = 0; xLines.length > l; l++) {
+ if (l == lineNumber) {
+ continue;
+ }
+ //
+ stringJoiner.add(xLines[l]);
+ }
+ //
+ return stringJoiner.toString();
+ }
+
+ public static String removeFirstLine(String x) {
+ return MText.removeLine(x, 0);
+ }
+
+ public static String removeLastLine(String x) {
+ if (null == x) {
+ throw new IllegalArgumentException("Invalid 'x': null.");
+ }
+ //
+ String[] xLines = x.split(System.getProperty("line.separator"));
+ //
+ return MText.removeLine(x, xLines.length - 1);
+ }
+
/* Javascript escape. */
public static String getJavascriptEscapedString(String x) {