Here you can find the source of substringLinesWithTokenOfEOL( String originalString, String stringToBeInserted)
Parameter | Description |
---|---|
originalString | :original string value to be processed |
stringToBeInserted | :value to be replaced into "#EOL#"(usually it's "\n") |
public static String substringLinesWithTokenOfEOL( String originalString, String stringToBeInserted)
//package com.java2s; public class Main { /**//from www . j a v a 2 s . c o m * Method to process String value with EOL mark * @param originalString :original string value to be processed * @param stringToBeInserted :value to be replaced into "#EOL#"(usually it's "\n") * @return String :string value of processed string */ public static String substringLinesWithTokenOfEOL( String originalString, String stringToBeInserted) { StringBuffer processedString = new StringBuffer(); int lastEnd = 0; for (int i = 0; i <= originalString.length(); i++) { if (i + 5 <= originalString.length()) { if (originalString.substring(i, i + 5).equals("#EOL#")) { processedString.append(originalString.substring( lastEnd, i)); processedString.append(stringToBeInserted); lastEnd = i + 5; } } else { if (i == originalString.length()) { processedString.append(originalString.substring( lastEnd, i)); } } } return processedString.toString(); } }