Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your data set is too simple to employ regular expressions. You can easily split the lines by <code>,</code> commas to parse your coordinates. Also, you probably need an <code>int[15][24]</code> here instead of <code>int[24][15]</code> if you want to store the coordinates as <code>int[rows][cols]</code> given that your grid is <code>24x15</code>.</p> <pre><code>int[][] coords = new int[15][24]; BufferedReader br = new BufferedReader(new FileReader("/path/to/file")); int row = 0; String line = null; while ((line = br.readLine()) != null) { // remove "[ ]" then split by "," String[] x = line.substring(1, line.length() - 1).split(","); // parse first 24 values only int cols = Math.min(x.length, 24); for (int col = 0; col &lt; cols; col++) { coords[row][col] = Integer.parseInt(x[col]); } if (++row &gt;= 15) break; // parse first 15 lines only } for (int i = 0; i &lt; coords.length; i++) { for (int j = 0; j &lt; coords[i].length; j++) { System.out.print(coords[i][j]); } System.out.println(); } </code></pre> <p><em><strong>Output</strong> :</em></p> <pre><code>53390038933333430314393653320333333 3333333333333333332133333 53390038933333430314393653320333333 3333333333333333332133333 53390038933333430314393653320333333 3333333333333333332133333 53390038933333430314393653320333333 3333333333333333332133333 53390038933333430314393653320333333 3333333333333333332133333 53390038933333430314393653320333333 3333333333333333332133333 53390038933333430314393653320333333 3333333333333333332133333 3333333333333333332133333 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload