Results 1 to 2 of 2
  1. #1
    applewood13 is offline Member
    Join Date
    Dec 2009
    Posts
    14
    Rep Power
    0

    Default Saving and loading information

    Hey, i'm trying to save a multi-dimensional variable array as a file so that it can be used when the program starts up again, what i'm trying to do is the following...

    Variables...

    |numbers1|numbers2|numbers3|numbers4|numbers5|numb ers6|numbers7|
    .......#............#............#............#... .........#............#............#
    .......#............#............#............#... .........#............#............#
    .......#............#............#............#... .........#............#............#

    where the # is a number input by the user, i want to save those numbers so when the program restarts i can retrieve that information and use it

    any help would be greatly appreciated :D
    Last edited by applewood13; 09-30-2010 at 04:25 AM.

  2. #2
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    You'll want a dual loop, one to loop through your outside array, and one to loop through each element of it. Example:
    Java Code:
    int[][] x = new int[3][7];
    // Set some data for x here
    for (int i = 0; i < x.length; i++) {
        for (int j = 0; j < x[i].length; j++) {
            // Some code using x[i][j], you can concat a string here to save to a file.
        }
    }
    (Link: Some info on multidimensional arrays in Java: Java: Two-dimensional arrays as arrays of arrays)

    Once you have your string created, use Java File I/O to communicate that data to a file. Information on that here.

Similar Threads

  1. Replies: 0
    Last Post: 08-02-2010, 11:26 AM
  2. Saving a file in a gui
    By rav in forum AWT / Swing
    Replies: 9
    Last Post: 07-07-2010, 06:27 PM
  3. Hi! Saving data??
    By Gahstanz in forum New To Java
    Replies: 1
    Last Post: 06-29-2010, 07:29 AM
  4. Saving JFrame
    By jralexander in forum New To Java
    Replies: 7
    Last Post: 12-03-2008, 10:19 PM
  5. Saving changes done through a program
    By xcallmejudasx in forum New To Java
    Replies: 0
    Last Post: 12-02-2008, 05:53 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
  •