aspose file tools*
The moose likes Beginning Java and the fly likes Using strings, etc. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using strings, etc." Watch "Using strings, etc." New topic
Author

Using strings, etc.

Anita Raj
Greenhorn

Joined: Mar 02, 2003
Posts: 7
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

Joined: Aug 03, 2002
Posts: 7729
Does it compile?
Does it run?
Does it work?
Does it throw an exception?


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Anita Raj
Greenhorn

Joined: Mar 02, 2003
Posts: 7
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

Joined: May 05, 2000
Posts: 13974
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?


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
Don't get me started about those stupid light bulbs.
 
subject: Using strings, etc.