• Post Reply Bookmark Topic Watch Topic
  • New Topic

Searching for a string in a file

 
sravan kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
 
SoonAnn Lim
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • 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.
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • 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.
 
sadanand varma
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
 
Sonara Rahul
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • 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.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!