Results 1 to 4 of 4
  1. #1
    DBaskov is offline Member
    Join Date
    Jan 2011
    Posts
    24
    Rep Power
    0

    Default Searching and replacing characters in a File

    Hello again. I have an assignment that I need to finish pretty soon, and I did a lot of research on this, but still could use some guidance. The project is about opening a file, searching the characters in it using CharAt I assume, and then replacing those characters. I think the hardest part of all is replacing characters in the file, from what I read its not that easy. The teacher said you can do it using String replace method, though from what I read else-where, I don't think that's possible because it involves a file. Can you actually do it that way? Is there any other way getting it done?

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Yeah, the replacement and the fact that its from a file are unrelated. Look into either a BufferedReader(FileReader(File)) combo, or the Scanner class. Once you have Strings in memory, search and replace is a single method call.

  3. #3
    DBaskov is offline Member
    Join Date
    Jan 2011
    Posts
    24
    Rep Power
    0

    Default

    Well I think he said you might do it by converting the file into string. Eitherway, if anyone knows what to do, I would much aprecciate if you could show me an example code or tell me which methods from classes to use.

  4. #4
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    He is correct... and I do know what to do... and I have told you where to start. Did you read my post?

Similar Threads

  1. searching in a saved file
    By GOhD in forum New To Java
    Replies: 1
    Last Post: 06-16-2010, 04:39 AM
  2. Help with reading / searching a .txt file
    By Absolute in forum New To Java
    Replies: 0
    Last Post: 03-11-2010, 06:39 AM
  3. Searching XML file using DOM
    By simon in forum XML
    Replies: 5
    Last Post: 03-30-2009, 02:27 AM
  4. Searching for Microsoft special characters
    By Tim McDaniel in forum Eclipse
    Replies: 2
    Last Post: 02-24-2009, 04:11 PM
  5. replacing characters???
    By manda147 in forum New To Java
    Replies: 2
    Last Post: 11-29-2008, 09:19 AM

Posting Permissions

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