-2

I have this array

String[][] someArrayOfData={{"there","is"},{"alot","of data here"}};

I want to be able to save this array so I can load and access it the next time I run the program. I dont mind having to use just a String[] as well. I have tried to write it to a notepad file but that is just a major irritation, is it possible to store variables externally to avoid the hassle of writing to multiple notepad files or using delineators?

MrT
  • 594
  • 2
  • 17
  • 2
    If you want to 'save' some data then you have to use either files or database. – wawek Aug 25 '15 at 06:21
  • 2
    Think about this from a technical standpoint. Where can you save data on a computer. Well you can mostly write it to memory, which is temporary, or the hard drive (through many different channels) which is permanent. – Kon Aug 25 '15 at 06:21
  • Database is your friend. – drgPP Aug 25 '15 at 06:22
  • Use any database to save the data and then access the data from database whenever the program starts running – Itban Saeed Aug 25 '15 at 06:23
  • Persistence takes many forms, have a look at [this discussion](http://stackoverflow.com/questions/19556932/how-to-save-the-state-of-my-minesweeper-game-and-then-load-it/19557052#19557052) for more details and options – MadProgrammer Aug 25 '15 at 06:23
  • You have to persist somewhere. Can go for the serialization, but since it is just strings, plain ascii file should suffice. – Sumit Trehan Aug 25 '15 at 06:26

1 Answers1

6

There are multiple possibilities. In all cases this is called persistence.

  1. Store to file Store to file
  2. Store to database Java DB tutorial
  3. Send it somewhere Simple REST web service and client

In principle 3 is not persistence, but it is a way to get the data out of the volatile memory.

Community
  • 1
  • 1
ACV
  • 9,964
  • 5
  • 76
  • 81