• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextPane/String index.

 
Sonara Rahul
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,
I have a query to find the index of a word in a string that is placed in JTextPane.
In a string i have a word say for example "is" which occurs more than thrice in that string.I need the indexs of is in a that string .
While trying to find the indexs I get only one index thats the index of last is.I need three index.
Culd anyone help me out in this regards.
Thanks in advance
Sonara
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you will have to create a while loop that runs as long as String.indexOf(//args) finds occurences and add the indices to some sort of collection, a LinkedList e.g.
from your posting I'd guess you haven't used a loop (there is no method that gives you all indices at once, you have to implement this functionality yourself).
post some code if you still have problems.
cheers
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!