List of usage examples for java.lang StringBuffer length
@Override public synchronized int length()
From source file:MainClass.java
public static void main(String[] arg) { StringBuffer aString = new StringBuffer("ABCDE"); int length = aString.length(); System.out.println(length);//from w ww . ja v a 2s.c o m }
From source file:MainClass.java
public static void main(String args[]) { StringBuffer sb = new StringBuffer("Hello"); System.out.println("length = " + sb.length()); }
From source file:Main.java
public static void main(String[] argv) { StringBuffer sb = new StringBuffer(); sb.append("java2s.com"); System.out.println(sb.length()); System.out.println(sb.capacity()); }
From source file:Main.java
public static void main(String args[]) { StringBuffer buffer = new StringBuffer("hello there from java2s.com"); char charArray[] = new char[buffer.length()]; buffer.getChars(0, buffer.length(), charArray, 0); System.out.print("The characters are: "); }
From source file:Main.java
public static void main(String[] argv) { StringBuffer sb = new StringBuffer(); sb.append("java2s.com"); System.out.println(sb.length()); System.out.println(sb.capacity()); sb.trimToSize();//from w ww.j a va2 s . c o m System.out.println(sb.length()); System.out.println(sb.capacity()); }
From source file:MainClass.java
public static void main(String args[]) { StringBuffer sb = new StringBuffer(40); System.out.println(sb);/*from w ww. j av a2s.c o m*/ System.out.println("Length: " + sb.length()); System.out.println("Capacity:" + sb.capacity()); }
From source file:FileDialogMultipleFileNameSelection.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); FileDialog dlg = new FileDialog(shell, SWT.MULTI); Collection files = new ArrayList(); if (dlg.open() != null) { String[] names = dlg.getFileNames(); for (int i = 0, n = names.length; i < n; i++) { StringBuffer buf = new StringBuffer(dlg.getFilterPath()); if (buf.charAt(buf.length() - 1) != File.separatorChar) buf.append(File.separatorChar); buf.append(names[i]);/*from w w w . j a va 2s . c o m*/ files.add(buf.toString()); } } System.out.println(files); display.dispose(); }
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[] args) { StringBuffer sb1 = new StringBuffer("Hello World"); sb1.delete(0, 6);// ww w .j av a 2 s. 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); }
From source file:MainClass.java
public static void main(String[] args) { StringBuffer sb = new StringBuffer("abc"); System.out.println("sb = " + sb); System.out.println("Length = " + sb.length()); System.out.println("Capacity = " + sb.capacity()); sb.setLength(2);//from w w w . j a v a 2 s . c om System.out.println("sb = " + sb); System.out.println("Length = " + sb.length()); System.out.println("Capacity = " + sb.capacity()); sb.setLength(4); System.out.println("sb = " + sb); System.out.println("Length = " + sb.length()); System.out.println("Capacity = " + sb.capacity()); }