-
I need help!
I have to write a program that accepts a URL from the user and
splits it into its 3 major components.
For example:
If your string is:
http://www.cnn.com/~cse110
your output should be
Protocol : http
Address : www.cnn.com
Resource : ~cse110
-
-
Well firstly StringTokenizer is deprecated so you shouldn't use that. You should use the split() method in the String class. It achieves pretty much the same result.
However, in this case you should look at the URL class. You can find information on it here. It parses URL's, and has methods for you to extract the information you need.
-
really? when did that happen?
-
well since its an intro class the instructor wants us to use tokenizer
-
Don't know when but I remember reading this about 6 months back at the API for StringTokenizer:
StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.
The split feature of String is pretty good. It puts all the "tokens" in an array of Strings. It also allows the use of regular expressions for splitting which makes it pretty powerful. I remember coding with Tokenizer was a big source of exceptions if I wasn't careful.
-
Originally posted by Yankeez
well since its an intro class the instructor wants us to use tokenizer
be sure to tell your instructor that this is the nineties; tokenizer is dead, let's split..
-
speaking of which, you can find a tutorial in my sig
-
be sure to tell your instructor that this is the nineties; tokenizer is dead, let's split..
This is the nineties? Now I'm confused.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|