title: android app error java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
body: <p>Hi I'm trying to modify the school schedule app github.com/LiquidPL/Kochanowski to show the schedule taken from the other website. I modified url in MasterlistDownloadRunnable.java to "<a href="http://gagla.h2g.pl/masterlist" rel="nofollow">http://gagla.h2g.pl/masterlist</a>" where I put url to my schedule <a href="http://liceumhs-wrze...lan/lista.html" rel="nofollow">http://liceumhs-wrze...lan/lista.html</a>. When I run the app and try to synchronize and download the html plan from my web the errors appear in this line:</p>
  
  <pre><code>shortName = new String (values[1].toCharArray (), 0, values[1].length () - 1);
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
  at
  com.github.LiquidPL.kochanowski.parse.handler.VulcanHandler.characters(VulcanHandler.java:192)
  </code></pre>
  
  <p>What else should I modify in code to be able to download schdule from my web?</p>
  
  <p>Here's code of VulcanHandler.java</p>
  
  <pre><code>public class VulcanHandler
          extends DefaultHandler
  {
      private TimeTableDownloadRunnable runnable;
      private int tableType;
  
      private String shortName;
      private String longName;
  
      private int currentLesson = -4;// currentLesson and currentDay are set to negative values
      private int currentDay = -3;   // because of the &lt;tr&gt; and &lt;td&gt; tags at the beginning of
                                     // the HTML file not containing any important data (so the indexing begins from 0)
      private String currentName = "";
      private String currentAttribute = "";
      private int currentGroup = 0; // 0 - current lesson is not grouped; -1 - current lesson is going to be grouped
                                    // 1 - group 1; 2 - group 2
      private String currentSubject = "";
      private String currentTeacher = "";
      private String currentClassroom = "";
      private String currentClass = "";
  
      private List&lt;String&gt; startTimes = new ArrayList&lt;&gt; ();
      private List&lt;String&gt; endTimes = new ArrayList&lt;&gt; ();
  
      /**
       * Class constructor
       *
       */
      public VulcanHandler (TimeTableDownloadRunnable runnable, int tableType)
      {
          this.runnable = runnable;
          this.tableType = tableType;
      }
  
      @Override
      public void startElement (String uri, String localName, String qName, Attributes attributes) throws SAXException
      {
          currentName = qName; // storing the name for use in other methods
          if ("tr".equals (qName)) // increasing the lesson number as we traverse the timetable
          {
              currentLesson++;
              currentDay = -3;
          }
          if ("td".equals (qName) || "th".equals (qName)) currentDay++; // same with the day
          if ("span".equals (qName) &amp;&amp; currentGroup == -1) // set the appropriate group number when in group mode
          {
              currentGroup = 1;
          }
          else if ("span".equals (qName) &amp;&amp; currentGroup == 1) // same as above
          {
              currentGroup = 2;
          }
          if ("span".equals (qName) || "a".equals (qName)) // if we hit elements that may contain timetable data,
          {                                                // we check if this is the case and store the information
              int length = attributes.getLength ();        // on what data may it be, so we can check it in
              for (int i = 0; i &lt; length; i++)             // characters () method
              {
                  String value = attributes.getValue (i);
                  // p - subject, n - teacher, s - classroom, o - class
                  // tytulnapis is a special case, it contains title of the timetable
                  if ("p".equals (value) || "n".equals (value) || "s".equals (value) || "o".equals (value) || "tytulnapis".equals (value))
                  {
                      currentAttribute = value;
                  }
                  if ("font-size:85%".equals (value)) // entering group mode, there will be two lessons within one hour here
                  {
                      currentGroup = -1;
                  }
              }
          }
  
          // inserting lesson for the first group, they are separated by a &lt;br/&gt; tag
          if ("br".equals (qName) &amp;&amp; currentGroup == 1 &amp;&amp; currentDay &gt;= 0 &amp;&amp; currentDay &lt;= 4 &amp;&amp;
                  !checkIfEmpty (currentSubject, currentTeacher, currentClassroom, currentClass))
          {
              DbWriter.insertLesson (
                      currentDay,
                      startTimes.get (currentLesson),
                      endTimes.get (currentLesson),
                      currentLesson,
                      currentGroup,
                      currentSubject,
                      currentTeacher,
                      currentClassroom,
                      shortName);
              currentSubject = ""; currentTeacher = ""; currentClassroom = ""; currentClass = "";
          }
      }
  
      @Override
      public void endElement (String uri, String localName, String qName) throws SAXException
      {
          // inserting lesson for the second group, or if the lesson is not grouped
          if ("td".equals (qName) &amp;&amp; currentDay &gt;= 0 &amp;&amp; currentDay &lt;= 4 &amp;&amp;
              !checkIfEmpty (currentSubject, currentTeacher, currentClassroom, currentClass))
          {
              if (currentGroup == 1 || currentGroup == 2)
              {
                  DbWriter.insertLesson (
                          currentDay,
                          startTimes.get (currentLesson),
                          endTimes.get (currentLesson),
                          currentLesson,
                          currentGroup,
                          currentSubject,
                          currentTeacher,
                          currentClassroom,
                          shortName);
              }
              else
              {
                  DbWriter.insertLesson (
                          currentDay,
                          startTimes.get (currentLesson),
                          endTimes.get (currentLesson),
                          currentLesson,
                          0,
                          currentSubject,
                          currentTeacher,
                          currentClassroom,
                          shortName);
              }
              currentGroup = 0;
              currentSubject = ""; currentTeacher = ""; currentClassroom = ""; currentClass = "";
          }
      }
  
      @Override
      public void characters (char[] ch, int start, int length) throws SAXException
      {
          String value = new String (ch, start, length).trim ();
          if (value.length () == 0) return;
          // next for ifs: storing timetable data for later insertion depending on the attribute
          if ("p".equals (currentAttribute))
          {
              currentSubject = value;
          }
          if ("n".equals (currentAttribute))
          {
              currentTeacher = value;
          }
          if ("s".equals (currentAttribute))
          {
              currentClassroom = value;
          }
          if ("o".equals (currentAttribute))
          {
              currentClass = value;
          }
          if ("td".equals (currentName) &amp;&amp; currentDay == -1) // storing the lessons begin and end hours
          {
              String[] values = new String (value.toCharArray (), 3, value.length () - 3).split ("-");
  
              // time must comply with the ISO 8601 standard, so we add a leading zero
              // to the time string if it's only 4 characters in length (eg. 8:55 goes into 08:55)
              if (values[0].length () == 4) values[0] = '0' + values[0];
              if (values[1].length () == 4) values[1] = '0' + values[1];
  
              startTimes.add (values[0]);
              endTimes.add (values[1]);
          }
          if ("span".equals (currentName) &amp;&amp; "-------".equals (value)) // this means that only group 2 has a lesson at this hour
          {
              currentGroup = 2;
          }
          // storing the timetable name, works different for class/teacher and classroom
          if ("span".equals (currentName) &amp;&amp; "tytulnapis".equals (currentAttribute))
          {
              String values[] = value.split (" \\(");
  
              longName = values[0];
           [b]   shortName = new String (values[1].toCharArray (), 0, values[1].length () - 1);[/b]
  
              if (tableType == Type.CLASS)
              {
                  DbWriter.insertClass (shortName, longName);
                  runnable.setTableName (longName + " (" + shortName + ")");
              }
  
              currentAttribute = "";
          }
      }
  
      /**
       * Checks if the entire set of lesson data have been already collected.
       * @param name Subject name
       * @param code Teacher code
       * @param room Classroom
       * @param _class Class
       * @return
       */
      private Boolean checkIfEmpty (String name, String code, String room, String _class)
      {
          if (name.length () != 0 &amp;&amp; code.length () != 0 &amp;&amp; room.length () != 0) return false;
          else if (_class.length () != 0 &amp;&amp; name.length () != 0 &amp;&amp; room.length () != 0) return false;
          else return !(code.length () != 0 &amp;&amp; _class.length () != 0 &amp;&amp; name.length () != 0);
      }
  }
  </code></pre>
  
  <p>full error log:</p>
  
  <pre><code>06-16 22:35:39.296  32122-32157/com.github.LiquidPL.kochanowski D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
  06-16 22:35:39.302  32122-32122/com.github.LiquidPL.kochanowski D/Atlas﹕ Validating map...
  06-16 22:35:39.349  32122-32157/com.github.LiquidPL.kochanowski I/Adreno-EGL﹕ &lt;qeglDrvAPI_eglInitialize:379&gt;: QUALCOMM Build: 01/14/15, ab0075f, Id3510ff6dc
  06-16 22:35:39.350  32122-32157/com.github.LiquidPL.kochanowski I/OpenGLRenderer﹕ Initialized EGL, version 1.4
  06-16 22:35:39.371  32122-32157/com.github.LiquidPL.kochanowski D/OpenGLRenderer﹕ Enabling debug mode 0
  06-16 22:35:41.078  32122-32157/com.github.LiquidPL.kochanowski D/OpenGLRenderer﹕ endAllStagingAnimators on 0xb4b6aa80 (RippleDrawable) with handle 0xaec2ce40
  06-16 22:35:41.600  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o1.html
  06-16 22:35:41.600  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o2.html
  06-16 22:35:41.600  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o3.html
  06-16 22:35:41.600  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o4.html
  06-16 22:35:41.600  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o5.html
  06-16 22:35:41.600  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o6.html
  06-16 22:35:41.601  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o7.html
  06-16 22:35:41.601  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o8.html
  06-16 22:35:41.601  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o9.html
  06-16 22:35:41.601  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o10.html
  06-16 22:35:41.601  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o11.html
  06-16 22:35:41.601  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o12.html
  06-16 22:35:41.601  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o13.html
  06-16 22:35:41.601  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o14.html
  06-16 22:35:41.601  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o15.html
  06-16 22:35:41.602  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o16.html
  06-16 22:35:41.602  32122-32180/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o17.html
  06-16 22:35:41.945  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o1.html
  06-16 22:35:41.945  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o2.html
  06-16 22:35:41.946  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o3.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o4.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o5.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o6.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o7.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o8.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o9.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o10.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o11.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o12.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o13.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o14.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o15.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o16.html
  06-16 22:35:41.947  32122-32122/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o17.html
  06-16 22:35:42.335  32122-32189/com.github.LiquidPL.kochanowski I/Process﹕ Sending signal. PID: 32122 SIG: 9
  06-16 22:35:53.899  32209-32229/com.github.LiquidPL.kochanowski D/OpenGLRenderer﹕ endAllStagingAnimators on 0xb4b6cc00 (RippleDrawable) with handle 0xaed6c2f0
  06-16 22:35:54.045  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o1.html
  06-16 22:35:54.045  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o2.html
  06-16 22:35:54.045  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o3.html
  06-16 22:35:54.045  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o4.html
  06-16 22:35:54.045  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o5.html
  06-16 22:35:54.046  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o6.html
  06-16 22:35:54.046  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o7.html
  06-16 22:35:54.046  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o8.html
  06-16 22:35:54.049  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o9.html
  06-16 22:35:54.049  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o10.html
  06-16 22:35:54.049  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o11.html
  06-16 22:35:54.049  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o12.html
  06-16 22:35:54.049  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o13.html
  06-16 22:35:54.050  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o14.html
  06-16 22:35:54.050  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o15.html
  06-16 22:35:54.050  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o16.html
  06-16 22:35:54.050  32209-32296/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o17.html
  06-16 22:35:54.400  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o1.html
  06-16 22:35:54.402  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o2.html
  06-16 22:35:54.402  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o3.html
  06-16 22:35:54.402  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o4.html
  06-16 22:35:54.403  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o5.html
  06-16 22:35:54.403  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o6.html
  06-16 22:35:54.403  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o7.html
  06-16 22:35:54.403  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o8.html
  06-16 22:35:54.403  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o9.html
  06-16 22:35:54.403  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o10.html
  06-16 22:35:54.403  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o11.html
  06-16 22:35:54.403  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o12.html
  06-16 22:35:54.403  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o13.html
  06-16 22:35:54.403  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o14.html
  06-16 22:35:54.404  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o15.html
  06-16 22:35:54.404  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o16.html
  06-16 22:35:54.404  32209-32209/com.github.LiquidPL.kochanowski I/liquid﹕ http://liceumhs-wrzesnia.pl/plan/plany/o17.html
  06-16 22:35:54.827  32209-32303/com.github.LiquidPL.kochanowski E/AndroidRuntime﹕ FATAL EXCEPTION: pool-1-thread-3
      Process: com.github.LiquidPL.kochanowski, PID: 32209
      java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
              at com.github.LiquidPL.kochanowski.parse.handler.VulcanHandler.characters(VulcanHandler.java:192)
              at org.apache.harmony.xml.ExpatParser.text(ExpatParser.java:163)
              at org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
              at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
              at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
              at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:316)
              at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
              at javax.xml.parsers.SAXParser.parse(SAXParser.java:390)
              at javax.xml.parsers.SAXParser.parse(SAXParser.java:187)
              at com.github.LiquidPL.kochanowski.parse.TimeTableDownloadRunnable.run(TimeTableDownloadRunnable.java:87)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
              at java.lang.Thread.run(Thread.java:818)
  </code></pre>