Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

loading past information

 
jake bellhorn
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whats the turtorial on loading previous information. what i mean for the hockey pool is if the person already has a league setup they click the button "resume" or something then itll just load the information from it. so that they dont have to start a new league everyday
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, the data needs to be stored somewhere outside of the JVM -- for example, on a hard drive. So the question becomes one of using Java I/O.

How exactly you go about doing this -- how complicated you make it -- depends on your application. It could be anything from a simple text file on the hard drive to serializing Java objects across a network.

I suggest starting with a text file. See the I/O section of the Java Tutorial or the I/O chapter of Thinking in Java.
 
jake bellhorn
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ive already done a text file i just need to noe how to load things
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jake bellhorn:
ive already done a text file i just need to noe how to load things

The above links on I/O topics will help you with that. Give it a try, and let us know if you run into specific problems.
 
jake bellhorn
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


is there any easier way of putting this code into this one code (below) so that the player makes the league then it when he closes the program he can come back to it and will load that file


thats all i have and ive got 2 weeks to finish this project. thanks for helping me with this so far
 
Campbell Ritchie
Sheriff
Posts: 48645
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you getting confused between where you are reading from?

You can read from a file. The simplest way to read a text file is to use the java.util.Scanner class (J5.0 only) which is very basic, but works nicely.

You can read from a JTextArea. Look up its method particularly those that look like getText().

Look up the constructor for FileWriter and see what happens if you put true after the file name.

BTW: If you are printing out an Exception message, it is usually done via the System.err PrintStream rather than System.out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic