Here you can find the source of collapseString(String data, String collapse)
Parameter | Description |
---|---|
data | the input String |
collapse | the data to collapse from the string. |
public static final String collapseString(String data, String collapse)
//package com.java2s; //License from project: Apache License public class Main { /**//w w w . ja va 2 s .c o m * Collapse a String from an input String. * @param data the input String * @param collapse the data to collapse from the string. * @return String */ public static final String collapseString(String data, String collapse) { if (data == null || collapse == null) return null; StringBuffer t1; int pos = data.indexOf(collapse); if (pos == -1) return data; t1 = new StringBuffer(); int start = 0; while (pos != -1) { t1.append(data.substring(start, pos)); start = pos + collapse.length(); pos = data.indexOf(collapse, start); } t1.append(data.substring(start)); return t1.toString(); } }