Changeset 245


Ignore:
Timestamp:
Mar 13, 2007, 4:19:22 PM (15 years ago)
Author:
Johan Enell
Message:

added a new method in BASEFileException and caught an exception in the reader

Location:
trunk/se/lu/onk/BaseFile/src/basefile
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/se/lu/onk/BaseFile/src/basefile/BASEFileException.java

    r149 r245  
    4343    super(e);
    4444  }
     45
     46  public BASEFileException(String message, Throwable e)
     47  {
     48    super(message, e);
     49  }
    4550}
  • trunk/se/lu/onk/BaseFile/src/basefile/BASEFileReader.java

    r186 r245  
    214214   */
    215215  public String[] readDataRow(int nbr)
    216     throws IOException, TooFewFieldsException, TooManyFieldsException
     216    throws BASEFileException, TooFewFieldsException, TooManyFieldsException
    217217  {
    218218    String[] vec = new String[nbr];
     
    223223      throw new TooFewFieldsException("Too few fields in " + section.getType() + ", line " + str.getLineNumber());
    224224    }
    225     if (!readLine() || dataEnd) return null;
    226 
    227     int tok = buf.indexOf("\t"), otok = 0;
    228 
    229     while (tok < buf.length())
    230     {
    231       tok = buf.indexOf("\t", otok);
    232       if (tok == -1)
    233       {
    234         tok = buf.length();
    235       }
    236       vec[vec.length - nbr] = buf.substring(otok, tok);
    237       otok = tok + 1;
    238       nbr--;
     225    try
     226    {
     227      if (!readLine() || dataEnd) return null;
     228
     229      int tok = buf.indexOf("\t"), otok = 0;
     230
     231      while (tok < buf.length())
     232      {
     233        tok = buf.indexOf("\t", otok);
     234        if (tok == -1)
     235        {
     236          tok = buf.length();
     237        }
     238        vec[vec.length - nbr] = buf.substring(otok, tok);
     239        otok = tok + 1;
     240        nbr--;
     241      }
     242    }
     243    catch (Exception e)
     244    {
     245      throw new BASEFileException("At line " + str.getLineNumber(), e);
    239246    }
    240247
Note: See TracChangeset for help on using the changeset viewer.