• Post Reply Bookmark Topic Watch Topic
  • New Topic

and after SEARCH for a any string like words or sentence or urls, for how many times appeared on pag

 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want from a "String location" take the URL obj, so run "String str = location.getContent();", and after SEARCH for a any string like words or sentence or urls, for how many times appeared on page[URL obj], can you help?
[code] private void getThePage( String location )
{
try // load document and display location
{
contentsArea.setPage( location ); // set the page
enterField.setText( location ); // set the text

String str = location.getContent();
index = str.indexOf("http://www.l-web-dev.net");

while (index !=0) {
index = str.indexOf("http://www.l-web-dev.net", index) ;
j++;

} [/code]
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There seems to be two questions there (or maybe more). I'm going to choose the one where it appears you want to read the data returned by a URL resource. There are examples of that in the Java Networking Tutorial.
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

well how I may get URL source code text String(all with once, since ABOVE may content go to next line, and get wrong results...), for searching in thereafter for a substring?
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You see in that code where you write each line to the console? Change it so that it appends each line to a StringBuilder instead. Then when the loop is finished, get a String from the StringBuilder.
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is any command get all txt file contents at once? or url source code txt file...
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code you have there, along with the change I suggested, will do it. If you're looking for a method in the standard API, then no.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!