• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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.

 
Wanna see my flashlight? How about this tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic