Skip to content

Loading and saving 2d arrays into a txt file?

Mario

Asked Jul 12, 2008, 2:27 AM EDT3 answers
Share
LinkedInX
Hi...

Im trying to make a software that would  save  2d arrays to a txt file and load them later....

Arrays have predefined size 160*365

Does anyone have an idea how I can do this?

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    StreamWriter sw = new StreamWriter("file.txt"); foreach(ArrayList row in Rows) { foreach(String cell in row) sw.Write(", " + cell); sw.WriteLine(""); } sw.Close()
    0
  • 0
    Java
    
    ArrayList Rows = new ArrayList();
    StreamReader sr = new StreamReader("file.txt");
    while(!sr.eof)
     {
       String str = sr.ReadLine();
    ArrayList row = new ArrayList();
       foreach(String s in str.split(new char[','])
         row.Add(s);
       Rows.Add(row);
    }
    0
  • 1 short reply
    • 0
      Thank you :D
      0