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:Main.java

public static void main(String[] argv) {
    StringBuffer sb = new StringBuffer(20);
    System.out.println(sb.capacity());
}

From source file:Main.java

public static void main(String args[]) {
    StringBuffer sb = new StringBuffer("java2s.com.");

    sb.deleteCharAt(0);/* ww w . ja v  a 2s.  co  m*/
    System.out.println("After deleteCharAt: " + sb);
}

From source file:Main.java

public static void main(String args[]) {
    StringBuffer sb = new StringBuffer("This is a test from java2s.com.");

    sb.replace(5, 7, "was");
    System.out.println("After replace: " + sb);
}

From source file:Main.java

public static void main(String args[]) {
    StringBuffer sb = new StringBuffer("java2s.com");
    System.out.println("buffer before = " + sb);

    sb.setLength(2);//from   w w  w  .  j a  v  a2s .  c o  m
    System.out.println("buffer after = " + sb);
}

From source file:Main.java

public static void main(String[] arg) {
    StringBuffer phrase = new StringBuffer("java2s.com");
    int position = phrase.lastIndexOf(".com");

    System.out.println(position);
}

From source file:Main.java

public static void main(String args[]) {
    StringBuffer buffer = new StringBuffer("hello java2s.com");

    System.out.println(buffer.charAt(0));
    System.out.println(buffer.charAt(4));

}

From source file:Main.java

public static void main(String[] arg) {

    StringBuffer buffer = new StringBuffer("from java2s.com");

    System.out.println(buffer.lastIndexOf("a", 10));
}

From source file:Main.java

public static void main(String[] arg) {

    StringBuffer buffer = new StringBuffer("from java2s.com");

    System.out.println(buffer.substring(2));
}

From source file:Main.java

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

    char[] text = { 'i', 's', ' ', 'e', 'x', 'a', 'c', 't', 'l', 'y' };
    buf.append(text, 2, 8);/*from  w ww  .ja v a  2  s .  c o m*/

    System.out.println(buf);
}

From source file:Main.java

public static void main(String[] arg) {

    StringBuffer buffer = new StringBuffer("from java2s.com");

    System.out.println(buffer.subSequence(1, 2));
}