Search an array with variable column sizes java
<p>I want to display some of the content of the .txt file on the screen after copying it into a new file. The content of the text file is not exactly the same structure throughout.</p>

<p>When i did this</p>

<pre><code>if (m[11].equals("Channel") &amp;&amp; m[12].equals("ID")){ System.out.println("Wavelenght ID = " + m[9]);
</code></pre>

<p>I got an error array out of bounds. </p>

<blockquote>
  <p>TESTSTEP: DEBUG <strong>* Fpga Config ECFG *</strong>:  EED                           3 : Channel ID</p>
</blockquote>

<p>If this line was found i want it to display Wavelenght ID = 3</p>

<pre><code>String p = path.replace("\\", "\\\\");
    File file = new File(p);
    File[]   files = file.listFiles();
    BufferedReader inputStream = null;
    PrintWriter outputStreamI = null;
    PrintWriter outputStreamO = null;

    try {
        String l,c;
        for (int i=0; i&lt;files.length; i++){

            inputStream = new BufferedReader(new FileReader(files[i].getAbsolutePath()));
            outputStreamI = new PrintWriter(new FileWriter("S:\\WRED_IBP\\" + files[i].getName().replaceFirst("[.][^.]+$", "")+ "Ingress.txt"));
            outputStreamO = new PrintWriter(new FileWriter("S:\\WRED_IBP\\" +files[i].getName().replaceFirst("[.][^.]+$", "")+ "Egress.txt"));  

            while ((l = inputStream.readLine())!= null) {
                String[] m=l.split(" ");
                for(int d=0; d&lt;m.length; d++){ 
                    c=m[d];
                    if (c.equalsIgnoreCase("ied_wred") ){outputStreamI.println(l); if (outputStreamI.checkError()){System.err.println("Error in output stream");}} //|| c.equalsIgnoreCase("WARNING") || c.equals("ERROR")
                    else if (c.equalsIgnoreCase("eed_brc_ibp")){outputStreamO.println(l); if (outputStreamO.checkError()){System.err.println("Error in output stream");}} // || c.equalsIgnoreCase("WARNING") || c.equals("ERROR") 
                }   
            }
        }

    } catch(IOException e){
        System.err.println("Caught IOException: " + e.getMessage());
    }//wait(10);
    finally {
        if (inputStream != null) {
            try{ inputStream.close();} catch (IOException e) {e.printStackTrace();}}
        if (outputStreamI != null) {outputStreamI.close();}
        if (outputStreamO != null) {outputStreamO.close();}

    }

}
</code></pre>
