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[] arg) {

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

    System.out.println(buffer.codePointCount(2, 3));
}

From source file:Main.java

public static void main(String[] arg) {

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

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

From source file:Main.java

public static void main(String[] arg) {

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

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

From source file:StringBufferDemo.java

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

    System.out.println("buffer = " + sb);
    System.out.println("length = " + sb.length());
    System.out.println("capacity = " + sb.capacity());
}

From source file:Main.java

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

    buf.append(aString, 3, 4);/*from   w  ww  . ja v a 2 s  .  co  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.offsetByCodePoints(1, 2));
}

From source file:Main.java

public static void main(String[] arg) {

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

    System.out.println(buffer.indexOf("ava", 2));
}

From source file:Main.java

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

    sb.setCharAt(1, 'i');
    System.out.println("buffer after = " + sb);
    System.out.println("charAt(1) after = " + sb.charAt(1));

}

From source file:IndexOfDemo.java

public static void main(String args[]) {
    StringBuffer sb = new StringBuffer("one two one");
    int i;//  ww w .ja  v  a2  s .c  o m

    i = sb.indexOf("one");
    System.out.println("First index: " + i);

    i = sb.lastIndexOf("one");
    System.out.println("Last index: " + i);
}

From source file:setCharAtDemo.java

public static void main(String args[]) {
    StringBuffer sb = new StringBuffer("Hello");
    System.out.println("buffer before = " + sb);
    System.out.println("charAt(1) before = " + sb.charAt(1));
    sb.setCharAt(1, 'i');
    sb.setLength(2);/*from  w ww . j av a  2 s .c  o  m*/
    System.out.println("buffer after = " + sb);
    System.out.println("charAt(1) after = " + sb.charAt(1));
}