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 3 of 3

Thread: Replacing text after a certain character or symbol in a text file

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    6
    My Mood
    Happy
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Replacing text after a certain character or symbol in a text file

    Can anyone lead me to the right direction on how to do this:

    I want toreplace all text after a certain character or symbol

    Say a line in the text file contains ":"

    I want everything after the ":" on that line to replaced with other text


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Replacing text after a certain character or symbol in a text file

    Store the entire line of text to a String variable.
    Use String method(s) to find the location/index of the certain character or symbol,
    Use other String method(s) to replace characters after the certain character or symbol with the desired characters.

    There are 2 or 3 other approaches that occur to me. Perhaps those or variations on the above outline will come to you as you learn about the available String methods on the String API page.

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Replacing text after a certain character or symbol in a text file

    you can use some different approaches...
    i'll try to write 2 of them...

    Code removed for spoonfeeding
    Last edited by jps; November 25th, 2013 at 06:32 PM. Reason: spoonfeeding

Similar Threads

  1. Replies: 1
    Last Post: May 18th, 2013, 11:28 PM
  2. Java code Split text file into multiple text file
    By jayraj in forum What's Wrong With My Code?
    Replies: 26
    Last Post: April 19th, 2013, 06:14 AM
  3. Beginner I/O Help: Writing To a Text File At the End of Existing Lines of Text
    By BloomingNutria in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: February 28th, 2012, 03:03 PM
  4. [SOLVED] Replacing words in a text file
    By sanelko in forum File I/O & Other I/O Streams
    Replies: 5
    Last Post: January 30th, 2012, 01:56 AM
  5. java program to copy a text file to onother text file
    By francoc in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: April 23rd, 2010, 03:10 PM

Tags for this Thread