Results 1 to 4 of 4
  1. #1
    lemontree45 is offline Member
    Join Date
    Oct 2010
    Posts
    25
    Rep Power
    0

    Default Find a text in a file and write a word following this word

    Hi all,

    I have a text file where I have to find a particular word1 and then add a word2 soon after this word. By using FileWriter I could do only writing to a file. But how to find the word and also followed by writing into it. Please help.

    Thanks & Regards

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,335
    Rep Power
    25

    Default

    But how to find the word and also followed by writing into it.
    What is the program supposed to do? Insert a String into a text file at a specific location?
    You need to read the file and copy its contents to a temp file, when at the location, write out the new word, then continue reading and copying the rest of the file. When finished, rename the original file or delete it and rename the temp file to the original name

  3. #3
    lemontree45 is offline Member
    Join Date
    Oct 2010
    Posts
    25
    Rep Power
    0

    Default

    Thank you for the help. I have already got the index number, where I have to enter the word. which command should I use to insert a word at that index number. I couldn't find one.

    I look forward to a reply.

    Thanks and regards

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,335
    Rep Power
    25

    Default

    which command should I use to insert a word at that index number.
    Sorry, I don't understand. Java doesn't have any commands.
    What is the index number? Are you trying to insert an element into an array?

Similar Threads

  1. Get selected text from MS Word,browser,pdf file
    By binhdinh0708 in forum New To Java
    Replies: 2
    Last Post: 04-17-2011, 04:04 PM
  2. Replies: 3
    Last Post: 11-09-2010, 12:10 AM
  3. Replies: 3
    Last Post: 06-26-2010, 08:11 AM
  4. Replies: 1
    Last Post: 02-28-2010, 03:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •