How to update a text file or change some text easily ??

Hi
I want to change some text inside a text file. I can do it as below:
1) new a File file
2) new a FileInputStream(file) and call read()
3) modify text
4) new a File newfile
5) new FileOutputStream(newfile) and call write()
6) delete file
7) rename newfile to file
It is too complecated. What is easy way to do it ? Thanks for help
Gary

Hi NLSurfMan,
I ceate a coding below , it always give me error:
java.io.FileNotFoundException: c:\abc\file.rtf (The process cannot access the file because it is being used by another process)
I have closed the FileReader and BufferedReader. I still have this problem. Why. Thanks. Gary
int c;
String text="";
File filename=new File("c:/abc/file.rtf");
FileReader fileReader =new FileReader(filename);
BufferedReader bReader=new BufferedReader(fileReader);
while ( (c=bReader.read())!=-1 ) {
text=text+(char)c;
bReader.close();
fileReader.close();
System.out.println("text="+text);
text=text+" I want to make some change here";
File filename1=new File("c:/abc/file.rtf");
BufferedWriter bWriter =new BufferedWriter(new FileWriter(filename1));
bWriter.write(text,0,text.length());
bWriter.close();

Similar Messages

  • How to update my podcast info and change some things

    Thanks in advance.
    My podcast information page: https://itunes.apple.com/au/podcast/in-all-airness-podcast/id568075066
    I am trying to change the name of my podcast to: In all Airness - Basketball Podcast
    I could even remove the word 'Podcast' from the title, it is redundant really...
    Also, I guess I should really have "amateur" as my type, it's not a professional podcast. I don't know why the length of time for first episode (around 58m) does not show, plus I have a nice short description of the first epsiode, but instead, the text from my actual blog post is what is listed within the show summary.
    I use Feedburner to send the RSS info to iTunes - how do I edit the XML file in FB? I can only view the XML source, not edit it - this is so annoying, would be most thankful if I could solve these issues!
    My website (where the blog post I mention, is located): inallairness.com
    Kind regards,
    Adam

    I should add, I can update some details (which have worked) using Feedburner (within Smart Cast area), but the things I wish to change (as mentioned in my main post above) are the things I can't seem to modify.
    Here's also the complete copy / paste of the XML source from my FB page:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2enclosuresfull.xsl"?>
    <?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?>
    <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
      <channel>
        <title>In all Airness » PODCAST</title>
        <link>http://inallairness.com</link>
        <description>Michael Jordan-era NBA - this is Basketball Central</description>
        <lastBuildDate>Sat, 06 Oct 2012 07:21:42 +0000</lastBuildDate>
        <language>en-US</language>
        <sy:updatePeriod>hourly</sy:updatePeriod>
        <sy:updateFrequency>1</sy:updateFrequency>
        <generator>http://wordpress.org/?v=3.4.2</generator>
        <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/inallairnesspodcast" />
        <feedburner:info uri="inallairnesspodcast" />
        <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />
        <itunes:owner>
          <itunes:email>[email protected]</itunes:email>
          <itunes:name>Adam Ryan</itunes:name>
        </itunes:owner>
        <itunes:author>Adam Ryan</itunes:author>
        <itunes:explicit>no</itunes:explicit>
        <itunes:image href="http://inallairness.com/wp/wp-content/uploads/airness.jpg" />
    <itunes:keywords>NBA,basketball,Jordan,Michael,Chicago,Bulls,podcast,Australia, humor,obsessed,high,profile</itunes:keywords>
        <itunes:subtitle>Michael Jordan-era NBA - this is Basketball Central</itunes:subtitle>
        <itunes:summary>An essential listen for basketball fans. My focus is Michael Jordan, but I cover plenty of topics including today's NBA. My point of difference is a unique Australian sense of humor and sharp focus on basketball past. A time when Shawn Kemp didn’t have children and Olden Polynice wasn’t impersonating police officers. Episodes feature occasional high-profile guests, mixed with a hefty dose of basketball-obsessed friends. Please take a moment to subscribe, so you can enjoy future episodes automatically.</itunes:summary>
        <itunes:category text="Sports &amp; Recreation">
          <itunes:category text="Professional" />
        </itunes:category>
        <item>
          <title>AIR Podcast 001 – Bill Wennington</title>
          <link>http://feedproxy.google.com/~r/inallairnesspodcast/~3/hYuzPmP2UT8/</link>
          <comments>http://inallairness.com/air-podcast-001-bill-wennington/#comments</comments>
          <pubDate>Thu, 04 Oct 2012 14:30:34 +0000</pubDate>
          <dc:creator>[email protected] (Adam Ryan)</dc:creator>
          <category><![CDATA[PODCAST]]></category>
          <category><![CDATA[Bill Wennington]]></category>
          <category><![CDATA[Michael Jordan]]></category>
          <category><![CDATA[NBA]]></category>
          <category><![CDATA[nostalgia]]></category>
          <guid isPermaLink="false">http://inallairness.com/?p=417</guid>
          <description>Two days ago I spoke with 3-time NBA Champion (Chicago Bulls), Bill Wennington. I live in Australia, some 15,000 kilometres (and change) from the shores of the USA. It&amp;#8217;s not possible to overplay how excited I am to have Bill &amp;#8230; &lt;a href="http://inallairness.com/air-podcast-001-bill-wennington/"&gt;Continue reading &lt;span class="meta-nav"&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/inallairnesspodcast/~4/hYuzPmP2UT8" height="1" width="1"/&gt;</description>
          <wfw:commentRss>http://inallairness.com/air-podcast-001-bill-wennington/feed/</wfw:commentRss>
          <slash:comments>0</slash:comments>
          <itunes:explicit>no</itunes:explicit>
          <itunes:subtitle>Two days ago I spoke with 3-time NBA Champion (Chicago Bulls), Bill Wennington. I live in Australia, some 15,000 kilometres (and change) from the shores of the USA. It&amp;#8217;s not possible to overplay how excited I am to have Bill &amp;#8230; Continue reading</itunes:subtitle>
          <itunes:author>Adam Ryan</itunes:author>
          <itunes:summary>Two days ago I spoke with 3-time NBA Champion (Chicago Bulls), Bill Wennington. I live in Australia, some 15,000 kilometres (and change) from the shores of the USA. It&amp;#8217;s not possible to overplay how excited I am to have Bill &amp;#8230; Continue reading &amp;#8594;</itunes:summary>
    <itunes:keywords>NBA,basketball,Jordan,Michael,Chicago,Bulls,podcast,Australia, humor,obsessed,high,profile</itunes:keywords>
          <feedburner:origLink>http://inallairness.com/air-podcast-001-bill-wennington/</feedburner:origLink>
          <enclosure url="http://feedproxy.google.com/~r/inallairnesspodcast/~5/bbtXA3pYsX8/AIR001-Bill-We nnington.mp3" length="58190447" type="audio/mpeg" />
    <feedburner:origEnclosureLink>http://inallairness.com/wp/wp-content/uploads/AIR001-Bill-Wennington.mp3</feedburner:origEnclosureLink>
        </item>
        <copyright>© 2012 In all Airness</copyright>
      </channel>
    </rss>
    <!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/
    Minified using disk: basic
    Page Caching using disk: enhanced
    Served from: inallairness.com @ 2012-10-06 17:33:23 -->

  • How to updating plugin.xml when it changed in 12C?

    After Importing the Plug-in Archive and Deploying it on Management Service with 12C, I need to make a change with plugin.xml in Plug-in Archive. Here it's the change,
    --- Old one:
    <PluginAttributes Type="MP" ReleaseStatus="Test"/>
    --- Change to:
    <PluginAttributes Type="MP" DisplayName="MySQL Database" Category="Databases"/>
    So I un-deployed Plug-in from Management Serbice, and used command "emcli import_update" to update the brand new OPAR file successfully, and the deployed again. But it seems the new plugin.xml didn't work at all, neither from UI nor the plugin.xml located under Management Server folder. I am sure it should work cause after I changed the Target Type and etc. in all related files to made a new plug-in, it works well.
    So how to updating plugin.xml when it changed in 12C? (It seems there is no option with MRS.)
    Thanks in advance!
    Best wishes,
    Satine

    Hey Caroy,
    Thank you for your help.
    It seems there is no entrance within page "Setup->Extensibility->Self Update" to delete a plugin. Would you please tell me more specific position?
    I will upgrade the version of plugin and try again to see if it works.
    Thanks,
    Satine

  • How to update a dbf file with gui_upload???

    hi friends,
    i would like to know how to update a dbf file with gui_upload???
    as i hve already know that it's easy to convert dbf to tab formatted text fle and thn upload it.but i want the direct uploading way.i don't let my user's bsy with converting existing dbf to txt.so pls help me asap!!!!!i will be thankful to you!!!!!

    its very easy you can search other forum!!!

  • How to update an image file into existing file

    how to update an image file into existing file

    Hi,
    So, i assume you want to change one picture. On Stage, i have edgeAnimate (an image), and
    1) i am using the div tag.
    So: sym.$("edgeAnimate").css("background-image", "url(images/myImage.png)" ); will change my picture.
    Link: CSS properties.
    More CSS:
    sym.$("edgeAnimate").css( { "background-image": "url(images/myImage.png)", "background-size": "100% 100%", "background-repeat": "no-repeat", "cursor": "pointer" } );
    Using a path variable:
    var myPath = "images/myImage.png";
    sym.$("edgeAnimate").css( { "background-image": "url("+myPath+")", "background-size":"100% 100%", "background-repeat":"no-repeat", "cursor": "pointer" } );
    2) i am using the img tag.
    I can add a class using Edge Animate user interface.
    I choose one class name: "newImage".
    So:  sym.$(".newImage").css("background-image", "url(images/myImage.png)" ); will change my picture.
    Note: I assumed you don’t need to preload your picture.

  • How to update cgicmd.dat file during runtime?

    I'd like to know how do update cgicmd.dat file during runtime. For example, I run a report one.jsp as
    http://<machine>:<port>/reports/rwservlet?one.jsp&USERID=uid/pwd@db&DESTYPE=cache&mode=bitmap&desformat=htmlcss
    within this report there is a hyperlink to open another report named two.jsp.
    before creating this hyperlink, I'd like to update cgicmd.dat file with passed in userID, pwd, and connection, so two.jsp can use this key for userinfo
    so I can create hyperlink as follows
    srw.set_hyperlink('/reports/rwservlet?report=two.jsp'||
    '&cmdkey=userinfo&DESTYPE=cache&mode=bitmap&desformat=htmlcss');
    Thanks

    To my knowledge the cgicmd.dat is only read when the OC4J starts, so you would have to come up with another solution. Using Single-Sign-On (SSO) is quite a good idea, and it's there for cases like this.
    Regards,
    Martin Malmstrom

  • How to update a text file?

    I am doing an assignment about a bank account. A text file stores the accounts.
    Account Text file:
    User1|Password1|Balance1
    User2|Password2|Balance2
    When user wants to deposit or withdraw the account, then how can update the balance.
    The problem is the length of balance is not fix. eg. $100 -> $90, vice versa.

    You cannot update a file that way. You're going to have to read the file and rewrite it in another file replacing the old balance value with the new balance value and then overwrite the old file with the new file.
    If the file is not to big you can load the whole file in memory with a String then work on that before rewriting it to the file.
    Otherwise your going to have to read chunks of lines and append them to a temporary file.
    I suppose this is no enteprise application but only a student's assignment, or else you should of course use a database for that kind of job!

  • How to update long text in symptoms/problems ?

    Hi All,
    Can anybody help me regarding how to update the long text of a symptom/problem?
    Please help.
    Regards,
    Jeetu

    Hi Jeetu,
    Can you Please elaborate your query.
    Are you talking about Problem/solutions created using Tcode: IS01( used in service scenario)
    Or
    The Text Management i.e. Text Types
    Regards.
    Shalini Chauhan

  • How to update session.xml file

    any body have an idea about how to update the session.xml file using Toplink workbench Editor.
    I have an Jar file which contains the session.xml file , so i am trying to update the session.xml file with me database details.

    any body have an idea about how to update the
    session.xml file using Toplink workbench Editor.
    For 10.1.3, see "Sessions Configurations and the sessions.xml File" in the TopLink Developer's Guide: http://www.oracle.com/technology/products/ias/toplink/doc/10131/main/_html/sesun002.htm#CACIGEBC
    For 10.1.2, see "OracleAS TopLink Sessions Editor" in the TopLink Mapping Workbench Guide: http://download.oracle.com/docs/cd/B14099_16/web.1012/b15900/tscedit.htm

  • How to update a versioned container with changes in the DB

    Hi,
    I've reverse engineered a database schema into a container, and then I versioned it as v1.0.
    Now, that schema has changed in the database, and I'd like to update the container with those changes, and version it as v2.0.
    What is the best way to do it?
    Is it posiible to capture only the changed or new items into the v1.0 container, and then version it as v2.0?
    Thanks

    Check the application in and then check it out
    This will take it to the next level of versioning.
    However the version will be like 1.1 and not 2.0.
    There is a way to make it 2.0 but I do not remember the steps.
    Once you check it out it will be identical to 1.0 but the version will be 1.1 and you can make your changes and the next time it is checked in and out it will be set to 1.2 etc.
    At this point I have to ask if versioning is realy what you want to do. Don't get me wrong Configuration managment is a great thing. However most people do not understand it or how to use it. And they usualy get themselves in trouble with it. So if you know what your doing with it then go for it.
    Hope this helps.
    Also once you version your repositry you cannot go back. You are versioned forever.
    Michael

  • How to update a war file safely

    Hi,
    I have a war file that has some files in it. I would like to update the war file to replace an existing web.xml file and add a new file in a different directory.
    I know that i can simply unzip the file and make the changes then zip it back again.
    I would like to do this using Ant but i was wondering if it is possible to do the update with only the updated files. I think the way ANT would work is it would check every file on the new directory and replace it if it is newer. The problem i have is i dont have copies of the existing files in the war file. I only have the files i want to replace in the war file. If i try it, will i end up with a new war file with just the new files and everything else deleted or will it just update the new file?

    Hi,
    Thank you for your response.
    A zip file is not really what i was querying about. I am working with a war file (Which is deployable on the application server) which is what i was asking about and probably why i didnt look at the zip task when i looked at the manual.
    I am using the war task to create the war file. When i looked at the manual (and googled it) i did find that i could use the update=true property on the war task to update the war file. Maybe i should have rephrased my question in another way. What i wanted to ask was if i use the update=true property will it:
    1. Update the war file with the new files and leave everything thing else unchanged.
    2. Replace the war file with a new one with just the new files.
    3. What happens if the new file i want to include has an older timestamp?
    As i mentioned earlier, i also know that i can rename the war file with .zip extension, unzip the war file using winzip, make the necessary changes and zip it back and rename it to a .war file. I dont really want to do this as it doesnt feel like its the right way to do it.
    Apologies if my initial post was not clear enough.

  • How to Update and XML file

    Hi,
    I'm reading an XML file using SAX api, now based on some calculations, i want to add a new Element inside the same XML file.
    <?xml version="1.0" encoding="UTF-8"?>
    <types>
    <type super = "City">
    <t>Faro</t>
    <t>Porto</t>
    <t>Helsinki</t>
    </type> 
    </types>Now in the above XML snippet, i want to add an new sub element <t> Islamabad </t>, inside types.
    Following is the point in the code where i'm stuck:
    for (int typeID = 0; typeID < typeList.size(); typeID++) {
                        Element type = (Element) typeList.get(typeID);
                        String superTypeStr = type.getAttributeValue("super").toString();
                        if (superTypeStr.equalsIgnoreCase(comboValue)) {
                             Element t = new Element("t");
                             t.addContent(typeValue);
                             //NOW HOW TO ADD THIS <t>, inside a matched type element (in this case "city"), and write it into the xml file
                             break;
    typeList is a List object, which i get using : typeList = types.getChildren("type");Hope i have explained the problem clearly, writing an XML fime from scratch is easy. but in my case i want to update an existing xml file with a new element entry.
    The XML file should need to be updated like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <types>
    <type super = "City">
    <t>Faro</t>
    <t>Porto</t>
    <t>Helsinki</t>
    <t>Islamabad</t>
    </type> 
    </types>--
    Regards Suleman

    hey mate, i remember when i had a similar issue before. I ended up using parsing the document using DOM instead of SAX. The reason being that i wanted to update the XML file and if i parsed the document using DOM i had a handle on the document object so i could subsequently update it. But the drawback is that the entire xml structure is parsed into memory, as opposed to SAX which im sure you know is event driven and memory friendly. I would use SAX for the simple process of parsing the xml file to either examine, or print out the content or both.Perhaps consider DOM?

  • How to update an XML file?

    hi,
    I am having an xml file like this.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE map [ <!ELEMENT map (entry*) >
    <!ELEMENT entry EMPTY >
    <!ATTLIST entry key ID #REQUIRED
    value CDATA "mydefault"> ]>
    <map>
    <entry key="key1" value="xxx"/>
    <entry key="key2" value="yyy"/>
    </map>
    I have written a DOMparsing program to parse this XML file. And the program is this,
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.stream.StreamSource;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.transform.TransformerException;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import java.io.File;
    import java.io.IOException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.DOMException;
    import org.w3c.dom.Attr;
    import org.w3c.dom.NodeList;
    public class DomExample
    public static void main(String args[])
    // Obtain an XML document; this method is implemented in
    Document doc = parseXmlFile("sample1.xml", true);
    //Getting elements by Tag name
    NodeList nodeList= doc.getElementsByTagName("entry");
    // Obtain an element
    Element element = (Element)(nodeList.item(0));
    element.removeAttribute("value");
    element.setAttribute("value", "Manivannan");
    try
    TransformerFactory tFactory =TransformerFactory.newInstance();
    StreamSource stylesource = new StreamSource();
    Transformer transformer = tFactory.newTransformer(stylesource);
    DOMSource source = new DOMSource(doc);
    //File f1 = new File("Sample3.xml");
    StreamResult result = new StreamResult(System.out);
    transformer.transform(source, result);
         catch(TransformerException te)
         te.printStackTrace();
    public static Document parseXmlFile(String filename, boolean validating) {
    try {
    // Create a builder factory
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(validating);
    DocumentBuilder builder = factory.newDocumentBuilder();
    // Create the builder and parse the file
    Document doc = builder.parse(new File(filename));
    return doc;
    } catch (SAXException e) {
    // A parsing error occurred; the xml input is not valid
    } catch (ParserConfigurationException e) {
    } catch (IOException e) {
    return null;
    Now what i am trying to do is replace value xxx in my xml with "Manivannan" and yyy with "gopalan"..But what i am getting during running this program is i am getting MalformedURL exception..Also will this program be able to update my xml with new values.If not possible pls let me know the method to update my xml file.
    Thanks for your reply in advance.

    Replace
    StreamSource stylesource=new StreamSource();
    Transformer transformer=tfactory.newTransformer(stylesource);with
    Transformer transformer=tfactory.newTransformer();

  • How to re-validate an import after changing some mappings?

    I imported a delimited text file into FDM. The import was successful.
    I then validated the import with the existing mappings. The validation was successful.
    I then exported the data to the target system (Essbase). The export was successful.
    I later found out that some of the mappings needed to be changed. For instance, instead of mapping A to X, I needed to map A to Y (both X and Y are valid targets).
    I thought after changing the mappings I would be able to go back to the workflow and just repeat the Validate step with the updated mappings, followed by the Export step (with the Replace option). What I found, however, is that none of the output records changed when I re-validated the import. The original mapping results were still in the output. It appears that re-validating didn't do anything at all. I had to repeat the entire workflow, starting over from importing the data, to get the updated mappings onto the output records.
    Is this the correct and expected behavior?  (I'm using FDM 11.1.1.2.).  Shouldn't I be able to make mapping corrections and have them take effect without having to re-import all of the source data?+
    I'm guessing there may be a logical reason for this behavior having something to do with archiving and/or auditing, since I successfully exported the data with the original mappings to the target system, but can anyone say for sure whether this is the way it's supposed to work and explain why?
    Thanks very much.

    Hi,
    If I Understand your issue correctly, You want to change some of the existing mappings and want to load the file again.
    I assume that the maps for that location is not derived from any other location. In the locations, the Parent location should be None, If not, You need to change the maps of the location metioned in the Parent location.
    Then update the grid and Please follow the workflow, It should reflect the changes you have done for the mappings.
    Regards,
    tvmk
    Edited by: tvmk on Mar 24, 2010 10:52 AM
    Edited by: tvmk on Mar 24, 2010 11:03 AM
    Edited by: tvmk on Mar 24, 2010 6:16 PM

  • How to Update existing XML File Using Java Swing

    Hi,
    I am reading XML file and getting keywords into JList. When i add some keywords into JList through textfield and remove keywords JList, then after click on save button it should update xml file. How can i do it ?
    Please provide me some code tips for updating xml file
    This is the code that i am using for reading XML File:
    import javax.swing.*;
    import java.awt.event.*;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    import java.io.IOException;
    import java.util.*;
    import java.text.Collator;
    import java.util.regex.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import com.cloudgarden.layout.AnchorConstraint;
    import com.cloudgarden.layout.AnchorLayout;
    public class getKeywords extends JFrame implements ActionListener
    static JPanel p;
    static JLabel lbl;
    static JButton btnSave,btnAdd,btnRemove;
    static String path;
    static Vector v;
    static JList lstCur;
    static JTextField txtKey;
    Document dom;
    static image imgval;
    NodeList nodelstImage;
    static AnchorLayout anchorLay;
    private DefaultListModel lstCurModel;
    public getKeywords()
         super("Current Keywords");
        v=new Vector();
        p=new JPanel();
        txtKey=new JTextField(10);
        btnAdd=new JButton("Add");
        btnRemove=new JButton("Remove");
        btnSave=new JButton("Save");
        lbl=new JLabel("Current Keywords");
        lstCurModel=new DefaultListModel();
            lstCur=new JList();
            JScrollPane scr=new JScrollPane(lstCur);
        runExample();
         lstCur.setModel(lstCurModel);
         p.add(lbl);
         p.add(scr);
         p.add(txtKey);
         p.add(btnAdd);
         p.add(btnRemove);
         p.add(btnSave);
         add(p);
         btnAdd.addActionListener(this);
         btnRemove.addActionListener(this);
         btnSave.addActionListener(this);
         setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    public static void main(String arg[])
         getKeywords g=new getKeywords();
         g.resize(250,400);
         g.setVisible(true);     
    public void actionPerformed(ActionEvent ae)
         if(ae.getSource()==btnAdd)
              lstCurModel.addElement(txtKey.getText());
         if(ae.getSource()==btnRemove)
              lstCurModel.remove(lstCur.getSelectedIndex());
         if(ae.getSource()==btnSave)
              //Code to Write
         public void runExample()
              //Parse the XML file and get the DOM object
              ParseXMLFile();
              //Get the Detail of the Image Document
              parseImageDocument();
              //Get the Detail of the LML Document
              //parseLMLDocument();
              //System.out.println(lmlval.Title);
         public void ParseXMLFile()
              //Get the Factory
              DocumentBuilderFactory builderFac = DocumentBuilderFactory.newInstance();
              try
                   //Using factory get an instance of the Document Builder
                   DocumentBuilder builder = builderFac.newDocumentBuilder();
                   //parse using builder to get DOM representation of the XML file
                   dom = builder.parse("LML.xml");
              catch(ParserConfigurationException pce)
                   pce.printStackTrace();
              catch(SAXException sax)
                   sax.printStackTrace();
              catch(IOException ioex)
                   ioex.printStackTrace();
         public void parseImageDocument()
              //Get the root element
              Element docImgEle = dom.getDocumentElement();
              //Get a nodelist for <Image> Element
              nodelstImage =  docImgEle.getElementsByTagName("Image");
              if(nodelstImage != null && nodelstImage.getLength() > 0)
                   for(int i = 0; i < nodelstImage.getLength(); i++)
                        //Get the LML elements
                        Element el = (Element)nodelstImage.item(i);
                        //Get the LML object
                        getImage myImgval = new getImage();
                        imgval = myImgval.getimage(el);
                        v.addElement(new String(imgval.Thumb));
                        String[] x = Pattern.compile(",").split(imgval.Keys);
                        for (int s=0; s<x.length; s++)
                        lstCurModel.addElement(x[s].trim());
                        //System.out.println(x[s].trim());
    }     Thanks
    Nitin

    You should update your DOM document to represent the changes that you want made.
    Then, using the Transformation API you simply transform your document onto a stream representing your file. Something like this:
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    // TODO - set indentation amount!
    Source source = new DOMSource(dom);
    Result result = new StreamResult(file);
    transformer.transform(source, result);Hope this helps.

Maybe you are looking for