Results 1 to 5 of 5

Thread: java.util.Scanner

Threaded View

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Resolved java.util.Scanner

    I started taking a look at some of the new classes in Java5 but i am a bit confused on how a Scanner uses delimiters. For instance take the following block of code.
    Code:
     String input = "1 fish 2 fish red fish blue fish";
     Scanner s = new Scanner(input).useDelimiter("\\s*fish\\s*");
     System.out.println(s.nextInt());
     System.out.println(s.nextInt());
     System.out.println(s.next());
     System.out.println(s.next());
     s.close();
    What is the "\\s*" used for? If the delimiter was
    specified as useDelimiter("fish"); wouldn't the output
    still be the same?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width