KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > lang > StringBuilder

java.lang
Class StringBuilder

java.lang.Object
  extended by java.lang.StringBuilder
All Implemented Interfaces:
Serializable, Appendable, CharSequence
See Also:
Top Examples, Source Code, StringBuffer, String

public StringBuilder append(boolean b)
See Also:
append(java.lang.String), String.valueOf(boolean)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder append(char c)
See Also:
Appendable, appended, String.valueOf(char)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder append(char[] str)
See Also:
appended, String.valueOf(char[])
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder append(char[] str,
                            int offset,
                            int len)
See Also:
appended, String.valueOf(char[],int,int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder append(double d)
See Also:
append(java.lang.String), String.valueOf(double)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder append(float f)
See Also:
append(java.lang.String), String.valueOf(float)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder append(int i)
See Also:
append(java.lang.String), String.valueOf(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder append(CharSequence s)
See Also:
IndexOutOfBoundsException, Appendable, CharBuffer
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder append(CharSequence s,
                            int start,
                            int end)
See Also:
IndexOutOfBoundsException, Appendable
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder append(Object obj)
See Also:
append(java.lang.String), String.valueOf(java.lang.Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder append(String str)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder append(StringBuffer sb)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder append(long lng)
See Also:
append(java.lang.String), String.valueOf(long)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder appendCodePoint(int codePoint)
See Also:
appended, Character.toChars(int), Character.charCount(codePoint)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int capacity()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public char charAt(int index)
See Also:
IndexOutOfBoundsException, CharSequence
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1457]Return the character to specific index
By suryaprakash on 2005/06/23 10:02:12  Rate
char s3='Prakash'; 
           String n=s3.charAt ( int 2 ) ; 
           System.out.println ( "return the character to specific index=="+n ) ; 
               


public int codePointAt(int index)
See Also:
IndexOutOfBoundsException, length()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int codePointBefore(int index)
See Also:
IndexOutOfBoundsException, length()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int codePointCount(int beginIndex,
                          int endIndex)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder delete(int start,
                            int end)
See Also:
StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder deleteCharAt(int index)
See Also:
StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void ensureCapacity(int minimumCapacity)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void getChars(int srcBegin,
                     int srcEnd,
                     char[] dst,
                     int dstBegin)
See Also:
IndexOutOfBoundsException, NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int indexOf(String str)
See Also:
NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int indexOf(String str,
                   int fromIndex)
See Also:
NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder insert(int offset,
                            boolean b)
See Also:
length(), insert(int, java.lang.String), String.valueOf(boolean), StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder insert(int offset,
                            char c)
See Also:
length(), IndexOutOfBoundsException, inserted, String.valueOf(char)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder insert(int offset,
                            char[] str)
See Also:
StringIndexOutOfBoundsException, inserted, String.valueOf(char[])
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder insert(int index,
                            char[] str,
                            int offset,
                            int len)
See Also:
StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder insert(int offset,
                            double d)
See Also:
length(), insert(int, java.lang.String), String.valueOf(double), StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder insert(int offset,
                            float f)
See Also:
length(), insert(int, java.lang.String), String.valueOf(float), StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder insert(int offset,
                            int i)
See Also:
length(), insert(int, java.lang.String), String.valueOf(int), StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder insert(int dstOffset,
                            CharSequence s)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder insert(int dstOffset,
                            CharSequence s,
                            int start,
                            int end)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder insert(int offset,
                            Object obj)
See Also:
length(), insert(int, java.lang.String), String.valueOf(java.lang.Object), StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder insert(int offset,
                            String str)
See Also:
length(), StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder insert(int offset,
                            long l)
See Also:
length(), insert(int, java.lang.String), String.valueOf(long), StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int lastIndexOf(String str)
See Also:
NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int lastIndexOf(String str,
                       int fromIndex)
See Also:
NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int length()
See Also:
CharSequence
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int offsetByCodePoints(int index,
                              int codePointOffset)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder replace(int start,
                             int end,
                             String str)
See Also:
StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1958]Fast String replacement
By Eduardo Valentim on 2008/03/07 06:35:49  Rate
public static StringBuilder replaceString ( StringBuilder text, 
     String search, String replace )   {  
   // Start searching for this index 
   int fromIndex = 0; 
  
  
   // Get the index for search pattern 
   int start = text.indexOf ( search, fromIndex ) ; 
   // If the search pattern don't exist in text 
   if  ( start == -1 )   {  
     // return 
     return text; 
    }  
  
  
   // if replace.length (  )   >  0 
   // is a replacement 
   // else 
   // is a deletion 
   if  ( replace.length (  )   >  0 )   {  
     // Initialize the end 
     int end = 0; 
     // Initialize the endAdjust to include or exclude caracters 
     // in replacement based on the rule below: 
     // 1 )  search.length (  )  == replace.length (  )  = >  0 
     // 2 )  search.length (  )   >   replace.length (  )  = >  +1,+2,... 
     // 3 )  search.length (  )   <   replace.length (  )  = >  -1,-2,... 
     int endAdjust =  ( search.length (  )  - replace.length (  )  ) ; 
     // Start the replacement 
     do  {  
       // calculate the end of replacement 
       end =  ( start + replace.length (  )  )  + endAdjust; 
       // replace 
       text.replace ( start, end, replace ) ; 
       // search for the last end  
       fromIndex = end; 
       // exist more search pattern in text? 
      }  while  (  ( start = text.indexOf ( search, fromIndex )  )  != -1 ) ; 
    }  else  {  
     // Start the deletion 
     do  {  
       // delete caracters from start to the search.length (  )  
       text.delete ( start, search.length (  )  ) ; 
       // search for the last end  
       fromIndex = start + replace.length (  ) ; 
       // exist more search pattern in text? 
      }  while  (  ( start = text.indexOf ( search, fromIndex )  )  != -1 ) ; 
    }  
  
  
   // Return the modified text 
   return text; 
  } 


public StringBuilder reverse()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setCharAt(int index,
                      char ch)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setLength(int newLength)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder(int capacity)
See Also:
NegativeArraySizeException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder(CharSequence seq)
See Also:
NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuilder(String str)
See Also:
NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1459]Building a string
By Anonymous on 2005/06/23 19:55:36  Rate
StringBuilder sb= new StringBuilder ( "How" ) ; 
 sb.append ( " Now" ) ; 
 sb.append ( " Brown" ) ; 
 sb.append ( " Cow" ) ; 
 String myNewString = sb.toString (  ) ; 
  
  
 //myNewString will be: 
 // "How Now Brown Cow"


public CharSequence subSequence(int start,
                                int end)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String substring(int start)
See Also:
StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String substring(int start,
                        int end)
See Also:
StringIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String toString()
See Also:
CharSequence
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void trimToSize()
See Also:
capacity()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags