File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes StringBuffer Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "StringBuffer" Watch "StringBuffer" New topic
Author

StringBuffer

Venkat Ramsimha
Ranch Hand

Joined: Dec 28, 2004
Posts: 127
public synchronized StringBuffer insert(int offset, String s)

Hi all
Can anybody provide a program with the implementation of the above method

Thanks&Cheers
venkat
Joe Sondow
Ranch Hand

Joined: Apr 10, 2005
Posts: 195
You can read the implementation code. It came with your JDK. Open your JDK folder and find the src.zip file. Unzip that file to a directory, and you can browse all of Sun's implementation code for the built-in classes, with the exception of native methods.

Here's the code for that method from the StringBuffer.java source file:


SCJA 1.0 (98%), SCJP 1.4 (98%)
Saranyan Narayanan
Ranch Hand

Joined: Mar 12, 2003
Posts: 34
Joe,
Venkat is probably asking , can a sample program show me how to use String buffer method insert()
Raghu Shree
Ranch Hand

Joined: Mar 18, 2005
Posts: 143
I just give the simple example of how to use the StringBuffer method insert(). Some of the different version of insert method is given below.
public java.lang.StringBuffer insert(int, boolean);
public synchronized java.lang.StringBuffer insert(int, char);
public java.lang.StringBuffer insert(int, int);
public java.lang.StringBuffer insert(int, long);
public java.lang.StringBuffer insert(int, float);
public java.lang.StringBuffer insert(int, double);
public java.lang.StringBuffer insert(int offset, char[] str);


Here argument no 1 means place of the position to be inserted.
argument no 2 means which type of representation to be inserteed.


Output of the above program is
Javatrue Programming
Java-true Programming
Java1-true Programming
Java1111-true Programming
Java1.01111-true Programming
Java1.01.01111-true Programming
Java Good1.01.01111-true Programming
JavaHello Good1.01.01111-true Programming
JavaHaiHello Good1.01.01111-true Programming


Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="http://groups.yahoo.com/group/scjp_share" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="http://groups.yahoo.com/group/JavaBeat_SCWCD" target="_blank" rel="nofollow">SCWCD Group</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: StringBuffer
 
Similar Threads
StringBuffer Class
Synchronized Code Behavior
String and StringBuffer
byte [ ] to StringBuffer
Copy of value and reference