• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Searching for a string in a file

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am facing with the problem its like this
I want to read a file and replace say "data.xml" string in the file with some other name say "data1.xml" but unable to do it can any one help me how to search a string in a file
Regards
shravan
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You open a file, open a bufferedReader to read in each line, construct a stringtokenizer object, then use .equal() method to search for the string to be replaced, then output to target file.
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, I am facing the same problem.
I dont know how the BufferReader can read from a file.
if one could specify a segment of code, I would be grateful...
Regards,
Jimi.
[This message has been edited by Jimi Rock (edited June 30, 2001).]
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Problem is solved. if any one wants me to provide him/her with the code, I will be ready.
Thanks for all...
Regards,
Jimi.
 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way to find text in a file without tracing through every single line? If the file is very large, this could be cumbersome.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
i need the code to search for a given string in a directory of files and display the files where it occured.
could u please send the code urgently
thanks
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jimi Rock:
Hi all,
Problem is solved. if any one wants me to provide him/her with the code, I will be ready.
Thanks for all...
Regards,
Jimi.


Reply:::::::::::
Hello Sir ,
I am also facing the same problem,I am able to read from Xmlfile,But i need to update a particular text in xml file .
Pl.. help me regarding this.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic