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 2 of 2

Thread: head help with file reading

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default head help with file reading

    I am making a program where i nead to read from a text file and based on whats in the text file, change how te program runs.

    Heres an example, lets say i have a format like whats below in the text file:

    #start
    Difficulty: normal;
    #tells the program to change the way it handles the graphics
    Graphics: fast;
    #tells the program how fast to run the game
    Game-speed: .1;
    #end

    this is just an example of what the file will look like, the # means s just a comment to be ignored by the program
    ; means the end of the task
    and the text behind the : means a command and the text infront means what command tells the program to do

    i have been trying for a while now to get my program to read the file correctly but i just can't figure it out with how to get the program to ignore # and to stop reading a line at ; and getting it to sucessfully read both numbers and letters

    does anyone have any suggestions on how to get this to work?


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: head help with file reading

    Read every word on this link to the scanner class and your current question, and many future questions you would have had, will be answered.

Similar Threads

  1. Cannot get my head around this :S
    By hillzyy in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: July 17th, 2012, 02:21 PM
  2. Replies: 3
    Last Post: December 2nd, 2011, 11:53 AM
  3. Need help with reading from .dat file
    By cyoung in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: April 26th, 2011, 07:34 AM
  4. Reading file
    By nasi in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 3rd, 2010, 03:14 AM
  5. Anyone Help me in XML file Reading??????????
    By goplrao in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: May 2nd, 2010, 11:04 AM