Results 1 to 2 of 2
  1. #1
    Games2Design is offline Member
    Join Date
    Sep 2012
    Posts
    44
    Rep Power
    0

    Default Scanner Delimiter

    Java Code:
    import java.util.Scanner;
    
    
    class ReadFromFile{
        public static void main(String[]args){
    
    	String text= "Hey, You, There!,Lol;, them.";
    	Scanner input=new Scanner(text);
            input.useDelimiter(",");
    
    	while(input.hasNext()){
    	    System.out.println(input.next());
    	}			  	
        }
    }
    
    [B]/* RESULT I WANT[/B]
    
    Hey
    You
    There
    Lol
    them
    
     */
    I want to use many characters as delimiters, but i don't know how.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,000
    Blog Entries
    7
    Rep Power
    20

    Default Re: Scanner Delimiter

    The delimeter used is a regular expression, so a delimeter "[;.,! ]+" should do the job. Read the API documentation for the Scanner class for details.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. identify the delimiter..
    By saidinu in forum New To Java
    Replies: 2
    Last Post: 09-28-2011, 05:16 PM
  2. Scanner delimiter issue
    By PrinceSendai in forum New To Java
    Replies: 3
    Last Post: 10-05-2010, 09:41 AM
  3. Replies: 1
    Last Post: 02-20-2009, 02:06 PM
  4. Use of Scanner class and Delimiter
    By tjhodge in forum New To Java
    Replies: 3
    Last Post: 02-12-2009, 05:26 PM
  5. delimiter
    By satin in forum New To Java
    Replies: 2
    Last Post: 11-17-2008, 10:50 PM

Posting Permissions

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