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: Read a text file and parse the contents of file

  1. #1
    Junior Member
    Join Date
    Jan 2011
    My Mood
    Thanked 0 Times in 0 Posts

    Question Read a text file and parse the contents of file

    Hi all,

    i have to read a text file, which contains information as follows:

    Posted: 2010-12-17 by Adil Basha [send email]

    Herrasment from Credit card executives inform u that i used a Credit card since last 2 years, numbered 5176521006890422, due to lost of my job i didnt pay the dues from last 3 months.help.

    Credit Card (complaint)

    Posted: 2010-12-16 by nileshpundkar [send email]

    cheating in settlement Hi,

    Last year my shopping amount was 3000 INR plus some previous amount not more than 3000, and including all the charges and late fees the toltal amount goes to 19000.

    I want it to be parsed, such that i can get the date, name of the person who sent this message. since there are blank lines in text file i am not knowing how to go about this.
    Can anyone tell how to parse this file?
    Thanks in advance.

  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    United Kingdom
    My Mood
    Thanked 294 Times in 227 Posts
    Blog Entries

    Default Re: Read a text file and parse the contents of file


    I would suggest taking a look at this code - http://www.javaprogrammingforums.com...ner-class.html

    Each line will be read in as a String which you can then manipulate and extract data from.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. How to read a text from an Image file?
    By GautamRy in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: October 5th, 2011, 05:02 AM
  2. Reading in entire contents of text file to one string
    By fortune2k in forum File I/O & Other I/O Streams
    Replies: 9
    Last Post: December 12th, 2010, 07:03 PM
  3. [SOLVED] parse txt file
    By maliv in forum File I/O & Other I/O Streams
    Replies: 16
    Last Post: November 17th, 2010, 03:54 PM
  4. java program to copy a text file to onother text file
    By francoc in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: April 23rd, 2010, 03:10 PM
  5. Read data from text file
    By yroll in forum Algorithms & Recursion
    Replies: 4
    Last Post: December 31st, 2009, 01:40 AM