title: ArrayIndexOutOfBoundsException: 4
body: <p>I'm writing a little program to analyze some data I have and this code, which worked yesterday, is no longer working.
  For the life of me, I can't tell why.  To my eye, everything is as it should be.  I've tried re-syncing the folder on my computer with my <a href="https://github.com/dedSea/WeatherProgram" rel="nofollow">GitHub Repo</a> and still was receiving the same error.  Maybe a second pair of eyes could help me out?</p>
  
  <p>The text file being read from can be found <a href="http://pastebin.com/8Q6YF1Bk" rel="nofollow">here</a>.</p>
  
  <p>Here are the methods referred to by the stack trace:</p>
  
  <pre><code>public static void main(String[] args) throws IOException{
      FileManagementMethods fmm = new FileManagementMethods();
      fmm.runProgram();
  
  }
  </code></pre>
  
  <p><p></p>
  
  <pre><code>void runProgram() throws IOException{
      boolean doesFileExist = doesFileExist();
      if(doesFileExist){
          int numLines = getNumberOfLines();
          String[] linesFromFile = getLines(numLines);
          WeatherAnalysisMethods wam = new WeatherAnalysisMethods();
          wam.parseFileAverageTemp(linesFromFile);
          wam.parseFileAverageHumidity(linesFromFile);
          wam.predictNextTemperature(linesFromFile);
      } else{
          try {
              throw new IOException("Could not find log.txt in default directory");
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p><p></p>
  
  <pre><code>void parseFileAverageHumidity(String[] linesFromFile) throws IOException{
      int[] humiditiesFromFile = new int[linesFromFile.length];
      humiditiesFromFile = getHumiditiesFromFile(linesFromFile.length);
      int averageFromFile = 0;
      for(int i = 0; i &lt; humiditiesFromFile.length; i++){
          averageFromFile += humiditiesFromFile[i];
      }
      averageFromFile = averageFromFile / humiditiesFromFile.length;
      String outString = "Average humidity for whole file = " + averageFromFile;
      FileManagementMethods fmm = new FileManagementMethods();
      fmm.saveAnalyzedData(outString);
  }
  </code></pre>
  
  <p><p></p>
  
  <pre><code>int[] getHumiditiesFromFile(int numLines){
      int[] humiditiesFromFile = new int[numLines];
      FileManagementMethods fmm = new FileManagementMethods();
      String[] lines = fmm.getLines(numLines);
      int i = 0;
      while(1 &lt; numLines){
          String[] lineDivides = lines[i].split(",");
          String tempString = lineDivides[4]; 
          humiditiesFromFile[i] = Integer.parseInt(tempString);
          i++;
      }
      return humiditiesFromFile;
  }
  </code></pre>
  
  <p><p>Line 51: </p>
  
  <pre><code>String tempString = lineDivides[4];
  </code></pre>
  
  <p>And here is the <b>stack trace</b>:</p>
  
  <pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
  at org.weatheralert.analysis.WeatherAnalysisMethods.getHumiditiesFromFile(WeatherAnalysisMethods.java:51)
  at org.weatheralert.analysis.WeatherAnalysisMethods.parseFileAverageHumidity(WeatherAnalysisMethods.java:22)
  at org.weatheralert.analysis.FileManagementMethods.runProgram(FileManagementMethods.java:22)
  at org.weatheralert.analysis.Main.main(Main.java:9)
  </code></pre>
  
  <p>If you guys need more information, don't hesitate to ask.</p>