Choosing between SAX & DOM & StringBuffer class for writing XML

Hii Javaties
I need to create a XML document from a swing application.
I need to store this xml in a file.
For writing XML which parser should i use SAX or DOM or should i go for StringBuffer class.

I'm not aware of a way to use SAX to create an XML document. It is used to view the contents of an existing XML document or data that is well-structured.
That leaves you with a choice of DOM or StringBuffer. We cannot tell enought about what you are doing to know which is better. Each has some advantages and disadvantages.
StringBuffer:
+ less overhead
- no assistance in ensuring the validity of the result
+ greater control over layout of resulting document (how and when to indent)
- any control over layout must be done by you.
DOM (although this task is easier in JDOM)
- more overhead
- some learning curve
+ result is guaranteed to be valid XML.
+ there are pretty formatters to generate good looking results
- there may be layout choices that the standard pretty formatters cannot do
As an example, consider this part of the Document being created.
You want <name>John Doe</name>
With a StringBuffer, you can just add these pieces. With DOM, you need to:
1) create an Element named "name".
2) create a Text object with a value of "John Doe".
3) add the Text object as a child of the Element
4) add the Element to the parent
Having done the DOM version (also a JDOM version) several times, I have developed an XMLHelper class that has several static methods to make simple, common constructs.
It lets me do things like:
parent.addChild( XmlHelper.makeElement( "name", customerName ) );
So, the answer to your question is the same as many other questions: It depends.
Dave Patterson

Similar Messages

  • Java API - Editor class for an XML schema

    Hi,
    i am very interesting in Java API. I would like to make an editor class for an XML schema. (I will create XML files in the current project based on this XML schema.) What step's are require for this editor class?
    Regards
    Gabor

    DavidThi808 wrote:
    jtahlborn wrote:
    you can provide a schema when parsing an xml document in order to check for schema conformance, but that isn't going to affect your XPath queries at all. DOM content is never anything but strings.In the case of both dom4j/jaxen and the .NET runtime the values returned from XPath queries when a schema is provided are typed. So you get back numbers, dates, and booleans as well as strings. And for numbers you get correct comparisons so 20 > 1.i guess it's possible. i use schemas when parsing xml, and i've used xpath (infrequently), but i'm not sure that i've ever used them together in a way that i would see functionality like that.
    FYI, you use http://docs.oracle.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilderFactory.html#setSchema%28javax.xml.validation.Schema%29 to specify a schema while parsing with a DocumentBuilder.

  • Need your help choosing between 2 audio/midi interface for logic

    Hi, new member here. I just signed-up just to ask for your recommendations.
    I am looking to buy either the Cakewalk UA-4fx (http://www.sweetwater.com/store/detail/UA4FX) or Tascam US-122mkII (http://www.sweetwater.com/store/detail/US122mk2).
    Do you have any advice on which one to get (or a third alternative if you know something that's similar but better)?
    I'm mainly looking to record from my Roland Fantom X keyboard to my Macbook (using Logic Pro). The effects/filters on the Cakewalk device is not that important to me (since I can use software effects), but the quality of sound is the most important. Also, ease-of-use and compatibility with Logic Pro is important. The device also must include MIDI-in/MIDI-out in addition to 1/4 inch direct line in for my synth. (I plan on using Midi-In/Midi-out with MainStage in Logic Studio). Not looking to spend too much more than $100.
    I think I read in a review that even though the Cakewalk UA-4fx has 2 inputs, it can only record 1 at a time. Is the same true of the Tascam or can it record 2 simultaneous tracks?
    But in short, sound quality AND compatibility with Logic Pro and MainStage are the main concerns. Does anyone have advice on choosing between the 2 or a third option if you know of one?
    Thanks in advance!

    Hello -
    It's been suggested to avoid, if possible, USB-based audio devices. My humble suggestion? I'd consider MOTU products. I own three MOTU audio devices (2408-MK3, 828-MK3 & 828-MK2) and all work just fine. The 828-MK3 has both midi and audio inputs & outputs (including ADAT inputs/outputs).
    Other people will, no doubt, suggest audio devices from other companies. All probably get the job done well. But if you're thinking about recording a lot of instruments at the same time, it is my understanding that it is best to avoid USB-based devices.
    Good luck with your search and your decision.

  • Where are classes for oracle.xml.parser.v2?

    I have downloaded both V1 and V2 of the XML parser. I have managed to download the java classes under org.w3c.dom from www.w3.org but I can't find the classes under oracle.xml.parser.v2 (or without v2) anyway on technet. Both are required for import.
    I would have expected them to be in the ZIP files xmlparser_v1_0_2_0.zip and xmlparser_v2_0_2_7.zip but they don't seem to be. These contain the equivalent HTML files but not the class files themselves, so compiling the samples is not possible.
    Any help would be appreciated as this is becoming very frustrating.
    Thanks in advance
    Gary

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Steve Muench ([email protected]):
    The xmlparserv2.jar in the 2.0.2.7 download contains everything you need from DOM and SAX interfaces in the jar.<HR></BLOCKQUOTE>
    Many thanks Steve - yes unzipping the jar file corrects problem.

  • Is there any ready made class for Writing out

    data type into a file?
    like something called FileOutput.class
    FileOutput out=new FileOutput("data_file.dat");

    Yeah, there are many, check out the java.io package:
    http://java.sun.com/j2se/1.4/docs/api/java/io/package-summary.html
    If you could be more specific, we could suggest what class you should use for your particular problem.

  • I want to load large raw XML file in firefox and parse by DOM. But, for large XML file the firefox very slow some time crashed . Is there any option to increase DOM handling memory in Firefox

    Actually i am using an off-line form to load very large XML file and using firefox to load that form. But, its taking more time to load and some time the browser crashed. through DOM parsing this XML file to my form. Is there any option to increase DOM handler size in firefox

    Thank you for your suggestion. I have a question,
    though. If I use a relational database and try to
    access it for EACH and EVERY click the user makes,
    wouldn't that take much time to populate the page with
    data?
    Isn't XML store more efficient here? Please reply me.You have the choice of reading a small number of records (10 children per element?) from a database, or parsing multiple megabytes. Reading 10 records from a database should take maybe 100 milliseconds (1/10 of a second). I have written a web application that reads several hundred records and returns them with acceptable response time, and I am no expert. To parse an XML file of many megabytes... you have already tried this, so you know how long it takes, right? If you haven't tried it then you should. It's possible to waste a lot of time considering alternatives -- the term is "analysis paralysis". Speculating on how fast something might be doesn't get you very far.

  • Architecture for writing XML information to Oracle DB

    Hi,
    I wish to design a java application that reads in an XML string from an Oracle database, parses this string and based on the tag values, inserts data from this XML doc to three Oracle temporary tables.
    I have the flexibility to either store the XML as a String or as a document in the Oracle database.
    Can anyone recommend how a solution for the issue above can be implemented?
    Thanks in advance.

    Does anyone has some pointers or clues?

  • Writing XML files

    Hello all
    There's a vast amount of information on the java.sun.com site about parsing XML files:
    * creating DOM trees in memory from an XML file
    * setting up event handlers to be called when an XML file is parsed
    * transforming XML files using XSL.
    However, I can find very little information anywhere about writing XML files in the first place! I'm already aware of two ways to do this:
    (1) create a DOM in memory and write this to a file. If the data is large, though, this isn't feasible.
    (2) just output the XML elements directly to some file as text. This doesn't take account of the encoding, or special characters, and the document is not necessarily then syntactically valid.
    Is there some API which I haven't yet come across that is designed specifically for writing XML data to files? If it's built in to Java 2, then goodness knows how I've missed it all this time; if it's third-party, I'd be grateful for any links.
    Thanks for your help
    Rich Fearn

    I know pastes can be horrible, but this is a working example which I find useful: SAX XML output ;)
    import java.io.*;
    // SAX classes.
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    //JAXP 1.1
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    import javax.xml.transform.sax.*;
                    //AlphabetXMLOut(file, alphabets);
    class AlphabetXMLOut {
            public void run(){
                    try{
                            FileOutputStream fos = new FileOutputStream("output.xml");
                            PrintWriter out = new PrintWriter(fos);
                            StreamResult streamResult = new StreamResult(out);
                            // PrintWriter from a Servlet
                            //PrintWriter out = response.getWriter();
                            //StreamResult streamResult = new StreamResult(out);
                            SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
                            // SAX2.0 ContentHandler.
                            TransformerHandler hd = tf.newTransformerHandler();
                            Transformer serializer = hd.getTransformer();
                            serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
                            serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"users.dtd");
                            serializer.setOutputProperty(OutputKeys.INDENT,"yes");
                            hd.setResult(streamResult);
                            hd.startDocument();
                            AttributesImpl atts = new AttributesImpl();
                            // USERS tag.
                            hd.startElement("","","USERS",atts);
                            // USER tags.
                            String[] id = {"PWD122","MX787","A4Q45"};
                            String[] type = {"customer","manager","employee"};
                            String[] desc = {"Tim@Home","Jack&Moud","John D'oe"};
                            for (int i=0;i<id.length;i++){
                                    atts.clear();
                                    atts.addAttribute("","","ID","CDATA",id);
    atts.addAttribute("","","TYPE","CDATA",type[i]);
    hd.startElement("","","USER",atts);
    hd.characters(desc[i].toCharArray(),0,desc[i].length());
    hd.endElement("","","USER");
    hd.endElement("","","USERS");
    hd.endDocument();
    fos.close();
    }catch (IOException e){
    System.err.println ("Unable to write to file");
    System.exit(-1);
    }catch (TransformerConfigurationException tce){
    System.err.println("Error in: TransformerConfigurationException");
    }catch (SAXException spe) {
    // Error generated by the parser
    System.err.println("Error in: (SAXException");
    // Use the contained exception, if any
    Exception x = spe;
    if (spe.getException() != null)
    x = spe.getException();
    x.printStackTrace();
    -Hope this helps

  • Okay so i have been trying to contact apple for days now but i was just thinking why do we have to only choose between white or black for the digitizer? would i be able to send my ipod into apple to get it customized to a different color besides that?

    okay so i have been trying to contact apple for days now but i was just thinking why do we have to only choose between white or black for the digitizer? would i be able to send my ipod into apple to get it customized to a different color besides that?

    Apple does not offer custom colors. I'd suggest you get a skin for your iPod. Those are available in hundreds of colors and patterns and since they're not permanent, they don't affect the iPod's warranty and you can change if you ever get tired of the skin you chose.
    Regards.

  • I bought a new Panasonic camcorder to edit in iMovie 10.0.3. I need to choose between the AVCHD choices and the ALL MP4/iframe choices. I don't have a clue as to which to use. I just want to burn video to DVD to have and share.  Thanks for any help.

    I bought a new Panasonic camcorder to edit in iMovie 10.0.3. I need to choose between the AVCHD choices and the ALL MP4/iframe choices. I don't have a clue as to which to use. I just want to burn video to DVD to have and share.  Thanks for any help.

    It sounds like you have assigned the primary click on the trackpad to something else, perhaps a gesture.
    Use your mouse, login and then open the Trackpad preference pane and see how you have the interface configured.
    Oh and you can have both the Magic Mouse and Magic Trackpad powered up and working at the same time. No need to keep moving batteries around.
    Tom

  • XML Validation using XDK SAX/DOM Parser

    Hello,
    I am trying to validate xml against xsd using SAX/DOM parser, both the files are stored as CLOB column in the database. I have the requirement to report all the validation errors and based on some helpful advice/code from the earlier posts in this forum, I have used the following code to validate and report the errors.
    The code works fine but for large files it never goes beyond a certain number of errors i.e. getNumMessages() (XMLParseException) never returns value greater than 100 and thus limits the output of the validation errors. Any pointers to suggest change in code or an alternative will be extremely helpful.
    Datebase Version : Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED <> as package <package name>;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.sql.SQLException;
    import oracle.sql.CLOB;
    import oracle.xml.parser.schema.*;
    import oracle.xml.parser.v2.*;
    import org.w3c.dom.*;
    public class XMLSchemaVal
    public static String validate(CLOB xmlDoc, CLOB xsdDoc)
    throws Exception
    //Build Schema Object
    XSDBuilder builder = new XSDBuilder();
    Reader xsdInUnicodeFormat = xsdDoc.getCharacterStream();
    XMLSchema schemadoc = (XMLSchema)builder.build(xsdInUnicodeFormat, null);
    //Build XML Object
    Reader xmlInUnicodeFormat = xmlDoc.getCharacterStream();
    // Genereate the SAX
    SAXParser saxparser_doc = new SAXParser();
    // Set Schema Object for Validation
    saxparser_doc.setXMLSchema(schemadoc);
    saxparser_doc.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    saxparser_doc.setPreserveWhitespace (true);
    String returnValue;
    try {
    saxparser_doc.parse (xmlInUnicodeFormat);
    returnValue = "The input XML parsed without errors.\n";
    catch (XMLParseException se) {
    returnValue = "Parser Exception: ";
    for (int i=0 ; i < se.getNumMessages(); i++)
    returnValue += "<LN: " + se.getLineNumber(i) + ">: " + se.getMessage(i);
    //returnValue = "Parser Exception: " + se.getNumMessages();
    catch (Exception e) {
    returnValue = "NonParserException: " + e.getMessage();
    return returnValue;
    Function to call the above utility from PL/SQL
    CREATE OR REPLACE FUNCTION F_XMLSCHEMAVALIDATION (P_XML IN clob ,P_XSD IN clob) RETURN VARCHAR2 IS
    LANGUAGE JAVA NAME XMLSchemaVal.validate(oracle.sql.CLOB,oracle.sql.CLOB) return java.lang.String';
    Thanks.

    Got the answer !!!
    NetBeans it self support generation of dtd file based on XML file.
    Open XML file and right click on the code block. Select option to generate dtd file.
    This is the drtd file it has generated..
    <?xml version='1.0' encoding='UTF-8'?>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT book (person)*>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT person (age|last|first)*>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT first (#PCDATA)>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT last (#PCDATA)>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT age (#PCDATA)>

  • Confusion for writing Crawling Data to Which XML Methods?

    Hi,
    I am stucked over here as i m going to use XML.
    Problem Having :-
    I have implemented the Crawling code .
    In which I have written the upcoming Main urls and and its sublinks in the Different Text File with the Incremented numbers.
    But in the Text files i can't see each and every URl's Grand Parent ,Parent and Child Relations.
    So, it generates the confusion and more time to see which URl having which Sublinks and its Text Files.
    Thinkable Approxiamte Solution from my side
    To use XML for Writing the Crawling processed all links Grant Parent, Parent and Child Relation Ships.
    Which can be useful for Traversing all the links Parent and Child relation Ship into only 1 XML file.
    XML files after that will used to read line by line and fetch the uRLs and that will used for other process ahead.
    Question Having:
    There are so many XML Methods available on the internet.(i.e. XMLwriting,XML Beans,Dom4j,XML Parser,SAX Parser,Dom Parser)
    So which method should i used for reading and writing the Crawling Parent and Child Relation ship using Good Schema.?
    Pls provide some code or useful links or any Suggetion which makes me to reach at solution.

    Use the Write Waveforms to File VI to write to a tab delimited text file.  Excel can open those up just fine.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • No serializer found for class com.sun.xml.messaging.saaj.soap.ver1_1.Messag

    Hi,
    I am developing a soap web service using apache axis tool. I am using tomcat6 and jdk6. I need to return SOAPMessage as return object from remote interface methods. Now I have success fully deploy web service in tomcat. Also I have create client too, but when I am trying to call web service throw client then it show me a exception on client is
    org.xml.sax.SAXParseException: Premature end of file.
    and on server log, it show me this exception
    java.io.IOException:
    xisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.io.IOException: No serializer found for class com.sun.xml.messaging.saaj.soap.ver1_1.M
    ssage1_1Impl in registry org.apache.axis.encoding.TypeMappingDelegate@98062f
    faultActor:
    faultNode:
    faultDetail:
           {http://xml.apache.org/axis/}stackTrace:java.io.IOException: No serializer found for class com.su
    .xml.messaging.saaj.soap.ver1_1.Message1_1Impl in registry org.apache.axis.encoding.TypeMappingDelegate@
    8062f
           at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1507)
           at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:980)
           at org.apache.axis.encoding.SerializationContext.outputMultiRefs(SerializationContext.java:1055)
           at org.apache.axis.message.SOAPBody.outputImpl(SOAPBody.java:145)
           at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:478)
           at org.apache.axis.message.MessageElement.output(MessageElement.java:1208)
           at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:315)
           at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:269)
           at org.apache.axis.Message.writeTo(Message.java:539)
           at org.apache.axis.transport.http.AxisServlet.sendResponse(AxisServlet.java:902)
           at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:777)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
           at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:2
    0)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:58
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:619)
           {http://xml.apache.org/axis/}hostname:EMRG-409964-L19
    ava.io.IOException: No serializer found for class com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl
    n registry org.apache.axis.encoding.TypeMappingDelegate@98062f
           at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
           at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:317)
           at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:269)
           at org.apache.axis.Message.writeTo(Message.java:539)
           at org.apache.axis.transport.http.AxisServlet.sendResponse(AxisServlet.java:902)
           at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:777)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
           at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:2
    0)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:58
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:619)
    aused by: java.io.IOException: No serializer found for class com.sun.xml.messaging.saaj.soap.ver1_1.Mess
    ge1_1Impl in registry org.apache.axis.encoding.TypeMappingDelegate@98062f
           at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1507)
           at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:980)
           at org.apache.axis.encoding.SerializationContext.outputMultiRefs(SerializationContext.java:1055)
           at org.apache.axis.message.SOAPBody.outputImpl(SOAPBody.java:145)
           at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:478)
           at org.apache.axis.message.MessageElement.output(MessageElement.java:1208)
           at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:315)
           ... 19 moreI have deploy new version of saa-impl.jar and saaj-api.jar too. And I also have deploy webservice-rt.jar too in server lib and application lib folder. but still this exception is there. I dont understand, how can I over come from this error. If some one have resolved this type of exception then please reply. Please reply me on [email protected]
    --Thanks in Advance
    Umashankar Adha
    Sr. Soft. Eng.
    United States

    FYI, now I'm in work:
    import javax.xml.namespace.*;
    import javax.xml.rpc.*;
    import javax.activation.*;
    import javax.mail.*;
    import com.sun.xml.messaging.saaj.*;
    -classpath D:\jwsdp-1.3\jaxp\lib\endorsed\dom.jar;D:\jwsdp-1.3\jaxp\lib\endorsed\xercesImpl.jar;D:\jwsdp-1.3\saaj\lib\saaj-impl.jar;D:\jwsdp-1.3\saaj\lib\saaj-api.jar;D:\jwsdp-1.3\jwsdp-shared\lib\activation.jar;D:\jwsdp-1.3\jwsdp-shared\lib\mail.jar;D:\jwsdp-1.3\jaxrpc\lib\jaxrpc-api.jar;D:\jwsdp-1.3\jaxrpc\lib\jaxrpc-impl.jar;D:\jwsdp-1.3\jaxrpc\lib\jaxrpc-spi.jar;D:\jwsdp-1.3\jwsdp-shared\lib\jax-qname.jar
    Those are what I had to use to get it working.
    Chris

  • What Are the Differences Between String and StringBuffer?

    Both String and StringBuffer are final classes. StringBuffer grows in size dynamically. Could people help to detail other differences between String and StringBuffer?

    String is immutable. In other words, once it is made, the contents of that instance of String cannot be changed (easily). The size and characters cannot be changed, and code can take advantage of this fact to optimize space. Also, once you have a reference to a string, you do not need to worry about it changing at all, so you can eliminate constant tests to verify things such as size in another class that may want to hold onto the string.
    StringBuffer, as you noticed, can change dynamically. While this provides flexibility, it cannot be optimized and assumptions cannot be made as with strings. If a class holds a reference to a StringBuffer that it does not own, there is a possibility that it may change things such as size when the class tries to use it later. StringBuffer is also less efficient in handling space then an equivalent String. The character array to hold a String is exactly the length to hold all the characters. StringBuffer, on the other hand, adds a 16 character buffer of array space for possible expansions. Also, the size of the internal array doubles when its internal capacity is exceeded. So, unless you explicitly maintain the size, a StringBuffer will take up more memory then an equivalent String, and if your program needs thousands of instances of Strings (which is not uncommon), that space can add up.
    I hope this helps clarify some things for you.
    -JBoeing

  • Versioning of SAX, DOM in WSDP versus SDK

    Packages for sax,dom etc provided in WSDP 1.1 are also in SDK 1.4
    Will these be moved out of the SDK and kept in WSDP in the future?
    Do the endorsed versions for WSDP differ at the present time?

    Packages for sax,dom etc provided in WSDP 1.1 are also
    in SDK 1.4
    Will these be moved out of the SDK and kept in WSDP in
    the future?
    Do the endorsed versions for WSDP differ at the
    present time?For J2SDk 1.4 the parser is crimson which does not support schemas. The jaxp jars in JWSDP contain most recent bugfixes and additional features. To override the older classes of jdk1.4 with the most recent one you need to use the endorsed standards. The future releases of JDK will contain sax, dom packages and maybe additional features but they will not be removed from the jdk.
    Regards,
    Bhakti

Maybe you are looking for

  • Converting Unix Date in Query

    <p>Hello everybody,</p><p> </p><p>i connect with brio 8.5 to a SQL database and get the unixdate.Is there a function or anything to convert this to the normaldate?</p><p>Or which formular can do this for me. Thank you inadvance.</p><p> </p>

  • Re: My iphoto '11 search function isn't working properly. Advice?

    When I search for a photo with a title beginning with 0, I get a huge number of photos that are not related to the photo number I'm searching. I've tried dropping initial 0 from a photo search, but that doesn't help.

  • How does weblogic render portal skeleton jsps?

    Hi, how does weblogic render shell? below is my shell file fragment, <netuix:head/> <netuix:body> <netuix:header> <netuix:jspContent contentUri="/framework/skeletons/header/pageHeader.jsp"/> </netuix:header> <netuix:jspContent contentUri="/framework/

  • Smart Collections: an ommission!?

    Hi, How do I create a smart collection that is based on another Collection, i.e. tests if an image exists or does not exist in a specified collection? When designed my workflow for Lightroom I realised that the Workflow is simply a series of concecut

  • Need help snycing photos from my pc to iphone

    I am running window vista and itunes 7.5 on my pc. my iphone is firmware 1.1.1. when i try to snyc my photos it doesn't work. i get an error. the error says "some photos were not copied to your iphone because they cannot be displayed on your iphone."