Example usage for java.lang StringBuffer StringBuffer

List of usage examples for java.lang StringBuffer StringBuffer

Introduction

In this page you can find the example usage for java.lang StringBuffer StringBuffer.

Prototype

public StringBuffer(CharSequence seq) 

Source Link

Document

Constructs a string buffer that contains the same characters as the specified CharSequence .

Usage

From source file:MainClass.java

public static void main(String[] arg) {
    StringBuffer newString = new StringBuffer("abcde1234567890");

    StringBuffer newBuffer = newString.append("saves nine");

    System.out.println(newBuffer);

}

From source file:MainClass.java

public static void main(String[] arg) {
    StringBuffer newString = new StringBuffer("abcde1234567890");

    newString.append("saves nine");

    System.out.println(newString);

}

From source file:MainClass.java

public static void main(String[] arg) {
    StringBuffer palindrome = new StringBuffer("so many dynamos");

    String aString = palindrome.toString();

    System.out.println(aString);/*w ww. ja  va2 s.  c o  m*/

}

From source file:MainClass.java

public static void main(String[] arg) {
    StringBuffer palindrome = new StringBuffer("so many dynamos");

    palindrome.reverse();//from  w  ww.j  av  a2  s.c o m

    System.out.println(palindrome);

}

From source file:Main.java

public static void main(String[] args) {
    StringBuffer sb = new StringBuffer("this is a test");

    System.out.println(sb);//from  w w w .j av a  2s  .  c o m
    String strPart1 = sb.substring(5);

    System.out.println(strPart1);
    String strPart2 = sb.substring(0, 17);

    System.out.println(strPart2);
}

From source file:MainClass.java

public static void main(String[] arg) {
    StringBuffer newString = new StringBuffer("abcde");

    System.out.println(newString.capacity());

    newString.ensureCapacity(40);/*ww w. j a  v  a2s  . c  o m*/

    System.out.println(newString.capacity());
}

From source file:MainClass.java

public static void main(String[] args) {
    StringBuffer sb1 = new StringBuffer("xy");
    System.out.println(sb1);//  w  ww . java  2s. c  o  m

    sb1.insert(0, false);
    System.out.println(sb1);

    StringBuffer sb2 = new StringBuffer("xy");
    System.out.println(sb2);

    sb2.insert(1, true);
    System.out.println(sb2);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    StringBuffer buf = new StringBuffer("Java this is a test");

    int index = 5;
    buf.insert(index, "Developers ");
    System.out.println(buf);//from   w  w w  . jav a2s.  c o m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    StringBuffer buf = new StringBuffer("Java this is a test");

    int index = 15;
    buf.setCharAt(index, '.');
    System.out.println(buf);/*from   w w w  .ja va 2s. co  m*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    StringBuffer buf = new StringBuffer("Java this is a test");

    int start = 27;
    int end = 28;
    buf.replace(start, end, "4"); // Java Developers v1.4
    System.out.println(buf);//from  w  w  w.j a  v a 2 s.c o m
}