CharSequence theseChars = new CharSequence(", "); CharSequence withTheseChars = new CharSequence("\n"); String newString = A.replace(theseChars, withTheseChars);
public static void main(String[] args) { String[][] array2d = createArray(); CharSequence charSequnce = new Array2DColumnCharSequnce(array2d, 0); boolean contentEquals = "Next Next ".contentEquals(charSequnce); System.out.println(contentEquals); CharSequence column1CharSequnce = new Array2DColumnCharSequnce(array2d, 1); String replaced = "I want to say Next Next ".replace(charSequnce, column1CharSequnce); System.out.println(replaced); }
CharSequence fileContent = new IOUtils.toString(new FileInputStream("file")); List<String> sentences = Splitter.on('.').trimResults().splitToList(fileContent);
String[] text = {"Address 1: Street nr.45 ", "Address 2: Street nr.67", "Address 3: Street nr. 56 \n Phone number: 000000000"}; String tempString = text[newSelectedAddress]; CharSequence charSeq= new SpannedString(tempString); Spannable spannable = (Spannable) charSeq; StyleSpan boldSpan = new StyleSpan(Typeface.BOLD); StyleSpan boldSpan2 = new StyleSpan(Typeface.ITALIC); spannable.setSpan(boldSpan, 0, "Address".length()-1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spannable.setSpan(boldSpan2, tempString.indexOf("Street"), tempString.indexOf("Street")-1 +"Street".length()-1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); ((TextView)findViewById(R.id.adresa)).setText(spannable);
public static void main(String[] args) { //String input = "12345"; //StringBuffer input = new StringBuffer("12345"); StringBuilder input = new StringBuilder("123"); //String separator = "<=>"; StringBuilder separator = new StringBuilder("<=");//.append('>'); int repeatCount = 2; CharSequence repSeq = new RepeatingCharSequence(input, repeatCount, separator); String repStr = repSeq.toString(); System.out.println("Repeat="+repeatCount+"\tSeparator="+separator+"\tInput="+input+"\tLength="+input.length()); System.out.println("CharSeq:\tLength="+repSeq.length()+"\tVal="+repSeq); System.out.println("String :\tLength="+repStr.length()+"\tVal="+repStr); //Here comes the Magic with a StringBuilder as Input, as you can append to the String-Builder //and at the same Time your Repeating-Sequence's toString()-Method returns the updated String :) input.append("ff"); System.out.println(repSeq); //Same can be done with the Separator: separator.append("===").append('>'); System.out.println(repSeq); }
CharSequence sp = new SpannableString(s); TextUtils.copySpansFrom((Spanned) source, start, end, null, (Spannable) sp, 0);
CharSequence charSequnce = new Array2DColumnCharSequnce(array2d, charSeqColumn);