bitmask flags within nested loops
<p>I am trying to use a bit mask to indicate whether there is a problem reading in text or not. </p>

<p>The code below is as I have it now but I would like to use a byte mask. Update it each time j is iterated in the second loop and declare the mask to reset after every line of text. </p>

<p>As I have it now I would only need a byte.</p>

<p>Reading token j would then look like this?
After make j of 'Integer' type and not 'int'</p>

<pre><code> if(j == 0)
 {
         it.i = token;
         mask = mask || j.byteValue();
         j++;
     }
</code></pre>

<p>-CODE-</p>

<pre><code>public void readText(String arg)
    {
        Scanner in = null;
        try
        {
            in = new Scanner(new File(arg));
        }
        catch (FileNotFoundException e)
        {
            System.out.println("Input .txt File not found");
        }

        int i = 0;
        while (in.hasNextLine())
        {
            int j = 0;
            Item it = new Item();
            String line = in.nextLine();
            StringTokenizer tkner = new StringTokenizer(line);
            while (tkner.hasMoreTokens())
            {
                String token = tkner.nextToken("|");

                //int wasJ = j;
                if(j == 0)
                    {it.i = token;j++;System.out.println("0T:" + token + "; 0j: " + j+ ";");}
                else if(j == 1)
                    {it.a = token;j++;System.out.println("1T:" + token + "; 1j: " + j+ ";");}
                else if(j == 2)
                    {it.c = token;j++;System.out.println("2T:" + token + "; 2j: " + j+ ";");}
                else if(j == 3)
                    {it.b = token;j++;System.out.println("3T:" + token + "; 3j: " + j+ ";");}
                else if(j == 4)
                    {it.d = token;j++;System.out.println("4T:" + token + "; 4j: " + j+ ";");}
                else if(j == 5)
                    {it.r = token;j++;System.out.println("5T:" + token + "; 5j: " + j+ ";");}
                else if(j == 6)
                    {it.d = token;j++;System.out.println("6T:" + token + "; 6j: " + j+ ";");}
                else if(j == 7)
                    {it.p = token;j++;System.out.println("7T:" + token + "; 7j: " + j+ ";");}

                //Replace field if empty.
              /*  if(wasJ+1 == j)// Okay, only one j iteration
                    ;
                else if(wasJ == j || wasJ&lt;j+1) //problem, we missed or skipped over a iteration
                {
                    if(j == 0)
                        {it.i = "-I";}
                    else if(j == 1)
                        {it.a = "-A";}
                    else if(j == 2)
                        {it.c = "-N";}
                    else if(j == 4)
                        {it.b = "-B";}
                    else if(j == 5)
                        {it.d = "-D";}
                    else if(j == 6)
                        {it.r = "-R";}
                    else if(j == 7)
                        {it.d = "-D";}
                    else if(j == 8)
                        {it.p = "-P";}
                }*/
            }
            i++;
            TheMasterList.addItem(it);
            it.print();
        }
        in.close();
        System.out.println("MasterSize:" + TheMasterList.Inventory.size());

        System.out.println(TheMasterList.Inventory.get(0).print());
        System.out.println(TheMasterList.Inventory.get(TheMasterList.Inventory.size()-1).print());
    }
</code></pre>
