List of usage examples for java.lang StringBuffer StringBuffer
public StringBuffer(CharSequence seq)
From source file:MainClass.java
public static void main(String[] arg) { StringBuffer newString = new StringBuffer(50); System.out.println(newString.capacity()); }
From source file:Main.java
public static void main(String[] arg) { StringBuffer aString = new StringBuffer("ABCDE"); String phrase = "abced"; StringBuffer buffer = new StringBuffer(phrase); System.out.println(aString);/* w ww .j av a 2s. c o m*/ System.out.println(buffer); }
From source file:MainClass.java
public static void main(String[] arg) { StringBuffer phrase = new StringBuffer("one two three four"); phrase.insert(4, "old"); System.out.println(phrase);//from w w w. j a va 2 s. c om }
From source file:MainClass.java
public static void main(String[] arg) { StringBuffer buf = new StringBuffer("The number is "); long number = 999; buf.append(number);//www . j a v a 2 s. c o m buf.append(12.34); System.out.println(buf); }
From source file:Main.java
public static void main(String args[]) { StringBuffer buffer = new StringBuffer("hello there"); System.out.printf("buffer = %s\n", buffer.toString()); System.out.printf("Character at 0: %s\nCharacter at 4: %s\n\n", buffer.charAt(0), buffer.charAt(4)); char charArray[] = new char[buffer.length()]; buffer.getChars(0, buffer.length(), charArray, 0); System.out.print("The characters are: "); }
From source file:MainClass.java
public static void main(String[] arg) { StringBuffer phrase = new StringBuffer("one two three four"); phrase.deleteCharAt(10);/* w ww.j av a 2 s . com*/ System.out.println(phrase); }
From source file:MainClass.java
public static void main(String[] arg) { StringBuffer phrase = new StringBuffer("one two three four"); phrase.delete(5, 9);//from w w w . j a v a2 s .c om System.out.println(phrase); }
From source file:MainClass.java
public static void main(String[] arg) { StringBuffer phrase = new StringBuffer("one two three four"); phrase.setCharAt(3, 'Z'); System.out.println(phrase);// w w w. j a va 2 s .c om }
From source file:MainClass.java
public static void main(String[] arg) { StringBuffer phrase = new StringBuffer("one two three four"); String substring = "two"; String replacement = "twenty"; int position = phrase.lastIndexOf(substring); // Find start of "two" phrase.replace(position, position + substring.length(), replacement); System.out.println(phrase);//from w ww . jav a 2 s . co m }
From source file:Main.java
public static void main(String[] args) { StringBuffer sb1 = new StringBuffer("Hello World"); sb1.delete(0, 6);//from ww w. j a va 2s. c o m System.out.println(sb1); sb1.delete(0, sb1.length()); System.out.println(sb1); sb1 = new StringBuffer("Hello World"); sb1.deleteCharAt(0); System.out.println(sb1); }