Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It appears that what they are doing is breaking the file down into two lists (or String arrays, in this case), one which contains all the even-numbered lines, and one which contains all the odd-numbered lines. I'll comment up the code for you:</p> <pre><code>public static String[][] ReadFilePerLine(Context context, String nom) { int i = 0; try { //open the specified input file and create a reader FileInputStream fIn = context.openFileInput(nom); InputStreamReader ipsr = new InputStreamReader(fIn); BufferedReader b = new BufferedReader(ipsr); //get the total number of lines in the file, and allocate //a buffer large enough to hold them all i = getLineNumber(context, nom); String[][] s = new String[2][i/2]; i = 0; //set the current line to 0 String ligne; int j = 0; //set the section index to 0 //now read through the lines in the file, and place every //even-numbered line in the first section ('s[0]'), and every //odd-numbered line in the second section ('s[1]') while ((ligne = b.readLine()) != null) { if (i % 2 == 0) //even-numbered line, it goes into the first section s[0][j] = ligne; else { //odd-numbered line, it goes into the second section s[1][j] = ligne; j++; //increment the section index } i++; //increment the line count } //done, cleanup and return fIn.close(); ipsr.close(); return s; } catch (Exception e) { //should at least log an error here... } } </code></pre> <p>As to why they chose to use a String[][], I cannot say. Probably for convenience, since they want a single object that they can return from this function that contains both lists. Personally I would use a Map that has two List instances in it, but the String[][] works just as well and is probably marginally more efficient.</p> <p>Judging from your example data it does not appear that you need to use this format. But if you want to use it, you need to structure your data so that the key is on one line, and its associated value is on the next, like:</p> <pre><code>date 2011-03-19 userName someGuy </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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