java - 2-Dimensional array storage -
i have stumbled upon problem. want store 2-dimensional int array in file read later. there way of doing other simple txt.file? it's first post here, , excuse english. (java programming language)
as indicated @andy can use objectoutputstream
serialize array file
int[][] intarray = new int[5][5]; //code populate array // serialize array fileoutputstream fos = new fileoutputstream("array.dat"); objectoutputstream oos = new objectoutputstream(fos); oos.writeobject(intarray);
and can read array file using objectinputstream
fileinputstream fis = new fileinputstream("array.dat"); objectinputstream iis = new objectinputstream(fis); intarray = (int[][]) iis.readobject();
hope helps.
Comments
Post a Comment