Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: FILE Input without delimiter.

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Thanked 0 Times in 0 Posts

    Default FILE Input without delimiter.

    Hi Java Experts,

    I need help in understanding this.

    This is my input from my text file: 1|John Jay Smith|1985-01-10|2010-05-10|2014-03-05|212-222-2233

    So, I have to convert 1 to integer. Break John Smith into first name as John and Middle name as Jay Last name as Smith.
    If no middle name is given then first is John and Last is Smith . Read 1985-01-10 as a date value . 2010-05-10 as another date value which could be null. 2014-03-05 as another date value which could be null. and at last 212-222-2233 as phone number.

    Scanner sc = new Scanner (inFile);
    while (sc.hasNext()){

    String row= sc.nextLine();

    I want to read this line of input and assign the value accordingly. How can I do that? Thanks for help

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    On vacation
    Thanked 2,425 Times in 2,378 Posts

    Default Re: FILE Input without delimiter.

    First split the record into fields using '|' as the delimiter. Then for the name field, split it using a space.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 6
    Last Post: March 24th, 2014, 06:19 AM
  2. Replies: 19
    Last Post: March 15th, 2013, 03:11 PM
  3. counting the values in input file and and writing the output to a file
    By srujirao in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 8th, 2012, 02:48 PM
  4. how to get value path file from jsp form- input type file
    By meeGoreng in forum JavaServer Pages: JSP & JSTL
    Replies: 4
    Last Post: October 4th, 2011, 12:05 AM
  5. Replies: 8
    Last Post: January 6th, 2010, 09:59 AM