Results 1 to 3 of 3
  1. #1
    mxsenevir is offline Member
    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Default Reading values from a text file

    I'm creating a gambling game where the user's info (first/last name, running total of winnings) is stored in a text file.

    If the user already has a file, it reads the file. The file looks like this:
    Name: Steve Jobs
    Balance: 300
    Rounds won: 5

    I was wondering how I could extract the value of Balance (in this example, 300) and use it as a variable so i could add/subtract to it everytime the player wins/loses.

    Thanks!

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: Reading values from a text file

    Option A
    Read entire line and split the 300 value out.

    Option B
    Read the text "Balance:"
    then read the int 300

  3. #3
    mxsenevir is offline Member
    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Default Re: Reading values from a text file

    Thanks! But how would that translate into code? Option B looks like the most straightforward

Similar Threads

  1. Replies: 8
    Last Post: 07-17-2011, 02:38 PM
  2. Extracting values from a text file
    By kryptonian03 in forum New To Java
    Replies: 4
    Last Post: 03-22-2011, 06:13 AM
  3. Replies: 14
    Last Post: 01-22-2011, 02:36 PM
  4. Reading Float values from a file
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:20 AM
  5. reading values from config file
    By sathish_2111 in forum Enterprise JavaBeans (EJB)
    Replies: 3
    Last Post: 08-10-2007, 03:09 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
  •