| | |
StringTokenizer: To searh and replace a word.
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2004
Posts: 3
Reputation:
Solved Threads: 0
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.
Any help would be appreciated.
•
•
Join Date: Sep 2004
Posts: 35
Reputation:
Solved Threads: 0
•
•
•
•
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
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 8
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
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
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 8
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
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
![]() |
Similar Threads
- Help with find and replace dialog in text editor application! (Java)
- Replace a Word in a .txt file (C++)
Other Threads in the Java Forum
- Previous Thread: search engine speeds
- Next Thread: Counting uppercase characters
| Thread Tools | Search this Thread |
Tag cloud for Java
affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth businessintelligence chat class classes client code component database desktop draw ebook eclipse encode equation error event exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer intersect j2me java javaexcel javaprojects jmf jni jpanel julia linked linux list loop mac main map method methods mobile netbeans newbie number online open-source oracle parameter print problem program programming project properties recursion reference replaysolutions rotatetext scanner score screen scrollbar server set size sms socket sort sql string superclass swing template test threads time tree windows working xstream





