HOME      BLOG       FORUMS      CONTACT       ABOUT

Replaces a substring with specified String from a StringBuffer

April 20th, 2008 Albin Joseph Posted in java.lang No Comments »

Replaces a substring with specified String from a StringBuffer

public class StringBufferExample {
public static void main(String[] args) {
StringBuffer buff = new StringBuffer("Hello World");
buff.replace(0, 5, "Hai");

System.out.println(buff);
}
}

AddThis Social Bookmark Button

Deletes a character at the specified index from a StringBuffer

April 20th, 2008 Albin Joseph Posted in java.lang No Comments »

Deletes a character at the specified index from a StringBuffer

public class StringBufferExample {
	public static void main(String[] args) {
		StringBuffer buff = new StringBuffer("Hello World");
		buff.deleteCharAt(0);

		System.out.println(buff);
	}
}
AddThis Social Bookmark Button

Deletes a substring from a StringBuffer

April 20th, 2008 Albin Joseph Posted in java.lang No Comments »

Deletes a substring from a StringBuffer

public class StringBufferExample {
	public static void main(String[] args) {
		StringBuffer buff = new StringBuffer("Hello World");
		buff.delete(0, 5);

		System.out.println(buff);
	}
}
AddThis Social Bookmark Button

Appends a String to the ends of a StringBuffer

April 20th, 2008 Albin Joseph Posted in java.lang No Comments »

Appends a String to the ends of a StringBuffer

public class StringBufferExample {
	public static void main(String[] args) {
		StringBuffer buff = new StringBuffer("Hello");
		buff.append("World");

		System.out.println(buff);
	}
}
AddThis Social Bookmark Button

Replaces a character of a StringBuffer

April 20th, 2008 Albin Joseph Posted in java.lang No Comments »

Replaces a character of a StringBuffer

public class StringBufferExample {
	public static void main(String[] args) {
		StringBuffer buff = new StringBuffer("Hello World");
		buff.setCharAt(1, 'E');

		System.out.println(buff);
	}
}
AddThis Social Bookmark Button

Copy the characters of a StringBuffer to a characters array

April 20th, 2008 Albin Joseph Posted in java.lang No Comments »

Copy the characters of a StringBuffer to a characters array

public class StringBufferExample {
	public static void main(String[] args) {
		StringBuffer buff = new StringBuffer("Hello World");

		char value[] = new char[5];
		buff.getChars(0, 5, value, 0);

		System.out.println(new String(value));
	}
}
AddThis Social Bookmark Button

Finds the character at a given position of a StringBuffer.

April 20th, 2008 Albin Joseph Posted in java.lang No Comments »

Finds the character at a given position of a StringBuffer.

public class StringBufferExample {
	public static void main(String[] args) {
		StringBuffer buff = new StringBuffer("Hello World");

		char value = buff.charAt(4);

		System.out.println(value);
	}
}
AddThis Social Bookmark Button

Sets the length of a StringBuffer

April 20th, 2008 Albin Joseph Posted in java.lang No Comments »

public class StringBufferExample {
	public static void main(String[] args) {
		StringBuffer buff = new StringBuffer("Hello World");
		buff.setLength(15);

		int value = buff.length();

		System.out.println(value);
	}
}
AddThis Social Bookmark Button

Sets the length of a StringBuffer

April 20th, 2008 Albin Joseph Posted in java.lang No Comments »

public class StringBufferExample {
	public static void main(String[] args) {
		StringBuffer buff = new StringBuffer("Hello World");
		buff.setLength(15);

		int value = buff.length();

		System.out.println(value);
	}
}
AddThis Social Bookmark Button

Trims the StringBuffer capacity to its size.

April 20th, 2008 Albin Joseph Posted in java.lang No Comments »

public class StringBufferExample {
	public static void main(String[] args) {
		StringBuffer buff = new StringBuffer(100);
		buff.append("Hello World");
		buff.trimToSize();
		int value = buff.capacity();

		System.out.println(value);
	}
}
AddThis Social Bookmark Button