Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Dekete Mutiple lines from file

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dekete Mutiple lines from file

    Need your help in below getting java code for below requirement

    I have a text file with the below details and we get the input as name CONNECTION_PORT and we need to delete the matching global variable which as CONNECTION_PORT and keep the remaining global variable in file without using any temp files. can you please help

    for example

    input:
    CONNECTION_PORT

    Text file

    <globalVariable>
    <name>CERTIFICATE_PASSWORD</name>
    <value>fgfdgfgf</value>
    <deploymentSettable>true</deploymentSettable>
    <serviceSettable>false</serviceSettable>
    <type>Password</type>
    <modTime>1398834966045</modTime>
    </globalVariable>
    <globalVariable>
    <name>CONNECTION_HOST</name>
    <value>localhost</value>
    <deploymentSettable>true</deploymentSettable>
    <serviceSettable>false</serviceSettable>
    <type>String</type>
    <modTime>1398834966045</modTime>
    </globalVariable>
    <globalVariable>
    <name>CONNECTION_PORT</name>
    <value>7833</value>
    <deploymentSettable>true</deploymentSettable>
    <serviceSettable>false</serviceSettable>
    <type>String</type>
    <modTime>1398834966045</modTime>
    </globalVariable>


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,707
    Thanks
    25
    Thanked 338 Times in 313 Posts

    Default Re: Dekete Mutiple lines from file

    You cannot partly modify a text file. Text files can either be fully written or appended. You can avoid a temp file by manipulating the file in memory. The process you would follow would be:
    1. Load the entire text file into memory
    2. Parse the file (possibly with an XML parser to make your life easier, since this seems to be XML)
    3. Delete the node you want to delete
    4. Write the entire text file back out (overwriting the input file)
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Similar Threads

  1. How to store all lines of a file
    By rajaveluswamy in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 8th, 2013, 04:38 AM
  2. Write to New lines in a file
    By ganapathi in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 10th, 2013, 11:28 AM
  3. Mutiple classfile, JPanel nothing shows up
    By Lorack in forum AWT / Java Swing
    Replies: 71
    Last Post: June 25th, 2012, 03:58 PM
  4. Mutiple JFrames Problems
    By mDennis10 in forum AWT / Java Swing
    Replies: 8
    Last Post: September 3rd, 2011, 11:24 PM
  5. How to assign values from a file to an arraylist of objects?
    By nadman123 in forum Collections and Generics
    Replies: 3
    Last Post: September 15th, 2008, 02:07 PM