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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 3 of 3

Thread: How to get certain info from a file line

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    11
    My Mood
    Amazed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to get certain info from a file line

    Ok so I'm making a little element quiz in the console that asks what the name of the element is after it gives you the element symbol, it's being read off a file and each line says the elements symbol and then the elements name
    (it looks like this)

    Th Thorium

    My question is how would I go about having it print out the element symbol and then compare the users answer to the element name, any help would be greatly appreciated.


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: How to get certain info from a file line

    Use String.split method.
    Improving the world one idiot at a time!

  3. #3
    Member
    Join Date
    Nov 2011
    Posts
    37
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: How to get certain info from a file line

    Hi,
    You can also use StringTokenizer

Similar Threads

  1. Problem to get info from HTML file
    By zecute in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: May 19th, 2011, 04:57 AM
  2. Reading a file line by line using the Scanner class
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: April 17th, 2009, 07:34 AM
  3. Reading a file line by line using the Scanner class
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: April 17th, 2009, 07:34 AM
  4. How to Read a file line by line using BufferedReader?
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 06:32 AM
  5. How to Read a file line by line using BufferedReader?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 06:32 AM