• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is any command get all txt file contents at once? or url source code txt file...
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
This tiny ad is suggesting that maybe she should go play in traffic.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic