Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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: 26912
82
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: 26912
82
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: 26912
82
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic