Hello! Help me to understand. It is necessary to read a text document with a matrix of characters and a number at the end. Here is an example:
o..o......ooooo..oo.. ....................o .o.....oooo..oo..o... 54
The matrix of symbols, respectively, must be written into a two-dimensional matrix or list, and the symbols, for example, will be true (o) -false (.), Or byte 0 (.) - 1 (o), or enum, not the essence. The number at the end must be written to the variable.
I was able to calculate only the matrix size, width and height:
private int width = 0; private int height = 0; public void read(){ try(BufferedReader bufferedReader = new BufferedReader(new FileReader("D:\\life\\test.txt"))) { String value; while ((value = bufferedReader.readLine()) != null) { if (width == 0) { width = value.length(); } height++; } System.out.println("Ширина:" + width + " Высота:" + (height-1)); } catch (IOException e) { e.printStackTrace(); } }
I tried the read () method, but it goes through all the characters at once until the end of the file.
Advise how to do?