I need help!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: I need help!

  1. #1
    Join Date
    Oct 2004
    Posts
    2

    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

  2. #2
    Join Date
    Mar 2004
    Posts
    635
    look up string Tokenizer

  3. #3
    Join Date
    Feb 2004
    Posts
    541
    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.

  4. #4
    Join Date
    Mar 2004
    Posts
    635
    really? when did that happen?

  5. #5
    Join Date
    Oct 2004
    Posts
    2
    well since its an intro class the instructor wants us to use tokenizer

  6. #6
    Join Date
    Sep 2004
    Posts
    150
    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.

  7. #7
    Join Date
    Feb 2004
    Posts
    808
    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..
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  8. #8
    Join Date
    Feb 2004
    Posts
    808
    speaking of which, you can find a tutorial in my sig
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  9. #9
    Join Date
    Sep 2004
    Posts
    150
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center