StringTokenizer: To searh and replace a word.

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2004
Posts: 3
Reputation: javaDumb is an unknown quantity at this point 
Solved Threads: 0
javaDumb javaDumb is offline Offline
Newbie Poster

StringTokenizer: To searh and replace a word.

 
0
  #1
Nov 29th, 2004
Hello all from javaDumb! I'm in my first java class and this is my first post so please be patient. I'm suppose to use StringTokenizer to search a document and replace some text, but the book for this course only explains how to print the text to the screen as tokens. I have created a class called editor with two constructors; one that has no parameters and one that passes one parameter(the document to be searched). I also have methods for getDocument(), setDocument(). This project also calls for two overloaded methods called replace(), one passes (search text, replace text) and the other passes (document, search text, replace text). I don't know how to use these and StringTokenizer together.

Any help would be appreciated.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 35
Reputation: tigerxx is an unknown quantity at this point 
Solved Threads: 0
tigerxx tigerxx is offline Offline
Light Poster

Re: StringTokenizer: To searh and replace a word.

 
0
  #2
Nov 29th, 2004
Originally Posted by javaDumb
Hello all from javaDumb! I'm in my first java class and this is my first post so please be patient. I'm suppose to use StringTokenizer to search a document and replace some text, but the book for this course only explains how to print the text to the screen as tokens. I have created a class called editor with two constructors; one that has no parameters and one that passes one parameter(the document to be searched). I also have methods for getDocument(), setDocument(). This project also calls for two overloaded methods called replace(), one passes (search text, replace text) and the other passes (document, search text, replace text). I don't know how to use these and StringTokenizer together.

Any help would be appreciated.

u can read the whole amount of text in doc together and

pass it to u r fun. ther u can use stringtokenizer to get each string from ur
whole content string and den u can use replace fun of string
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 3
Reputation: javaDumb is an unknown quantity at this point 
Solved Threads: 0
javaDumb javaDumb is offline Offline
Newbie Poster

Re: StringTokenizer: To searh and replace a word.

 
0
  #3
Dec 1st, 2004
Thank you tigerxx for the reply, but I'm still quite lost on how this is done.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 8
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: StringTokenizer: To searh and replace a word.

 
0
  #4
Dec 3rd, 2004
Hi everyone,
I am currently trying to do what you are doing now
see this thread

http://www.daniweb.com/techtalkforums/thread14899.html

but the thing is that function that i wrote only runs perfectly once and it can't search
anyting after calling that function.

It's really weird but you can use that function if you like and if you happen to be able to find solution to my problem please let me know as i really need help for that

Yours Sincerely

Richard West
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 3
Reputation: javaDumb is an unknown quantity at this point 
Solved Threads: 0
javaDumb javaDumb is offline Offline
Newbie Poster

Re: StringTokenizer: To searh and replace a word.

 
0
  #5
Dec 4th, 2004
I'll give it a try freesoft_2000, will let you know if i have any better luck.

Thank you,

Kevin Ervin
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 8
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: StringTokenizer: To searh and replace a word.

 
0
  #6
Dec 4th, 2004
hi everyone,
Kevin i managed to do it. Firstly do not pass the pos1(the Jtextpane's current position) into the function but read it inside the function. That's why my function was working only once as i was always reading the same position. By the way if you are using a dialog make sure it it not modal and always to grab the focus of your text component.

Yours Sincerely

Richard West
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC