Since a 2D char array is nothing but an array of char arrays, you can convert the char array to a String using String.valueOf()
and write it out to a file using PrintWriter
. When reading in data, just read in lines of data and recreate your 2d char array using String.toCharArray()
.
Another interesting thing you can try out is to write out Java arrays as JSON which will render it usable by any application without having a proprietary format for your text file.