0
public void writeArraytofile() {
    try {
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(openFileOutput("array.txt", Context.MODE_PRIVATE));
        outputStreamWriter.write(Arrays.toString(array));
        outputStreamWriter.close();
    } catch (IOException e) {
        Log.v("MyActivity", e.toString());
    }
}

I think I've found how to write an array to a file, but I still do not know how to read one. Can someone show me how it works?

John Solly
  • 31
  • 5
  • 1
    What are you trying to do? Read a file into an array? Clarify in the body of the question. –  Aug 18 '17 at 14:57
  • I am trying to read the array that I have saved @jdv – John Solly Aug 18 '17 at 14:59
  • You can use a Reader to fetch the data from the file, but I think you might be going at this the wrong way. I'm not even sure you really want to write out the contents this way (read up on what Arrays.toString() really does.) However, what you are doing is sort of writing your own serialization/deserialization routines. –  Aug 18 '17 at 15:07
  • Related: https://stackoverflow.com/q/5343689/1531971 and https://stackoverflow.com/q/13707223/1531971 –  Aug 18 '17 at 15:09

0 Answers0