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

Popular posts from this blog

ios - Is 'init' forbidden as *part* of a variable name? -

file - Python: AttributeError: 'str' object has no attribute 'readlines' -

c# - Get the Class name in a class with atribute inside a attribute method -