Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using strings, etc.

 
Anita Raj
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to print out ALL links present in a page (the page is in HTML). Can someone tell me how to do this...what's wrong with this code...anything! Thanks.

[ March 23, 2003: Message edited by: Anita Raj ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it compile?
Does it run?
Does it work?
Does it throw an exception?
 
Anita Raj
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I compiled it, these errors came:

java.lang.StringIndexOutOfBoundsException: String index out of range: -729
at java.lang.String.substring(String.java:1503)
at Proj.ReturnURL.ParsePage(ReturnURL.java:42)
at Proj.ReturnURL.main(ReturnURL.java:50)
Exception in thread "main"
[ March 23, 2003: Message edited by: Anita Raj ]
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you think it's very efficient to allocate an array of 1,000,000 bytes? Would it make more sense to wrap your FileInputStream with a BufferedInputStream so that you can do readLine()? And shouldn't you be using FileReader to read character data?
What does your program do if it doesn't find the string it is searching for (either "a href=" or "/")? What does the indexOf return when it doesn't find a String? What effect would that have on your program? How do you ever get to the end of your while loop?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic