/** Read table from the data source. */
  public void readTable(CyTable table) throws IOException {
    // InputStream is = null;

    try {
      BufferedReader bufRd = null;

      if (is == null) {
        is = URLUtil.getInputStream(source);
      }
      try {

        // This data is shared by both the OpenCSV and the old method of reading files.
        int lineCount = 0;
        bufRd =
            new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8").newDecoder()));
        /*
         * Read & extract one line at a time. The line can be Tab delimited,
         */
        final String delimiter = mapping.getDelimiterRegEx();

        // If the delimiter contains a comma, treat the file as a CSV file.
        if (delimiter.contains(TextFileDelimiters.COMMA.toString())
            && mapping.getDelimiters().size() == 1) {
          // Use OpenCSV.. New method...
          CSVReader reader = new CSVReader(bufRd);
          String[] rowData; // Note that rowData is roughly equivalent to "parts" in the old code.
          while ((rowData = reader.readNext()) != null) {
            // If key dos not exists, ignore the line.
            if (lineCount >= startLineNumber && rowData.length >= mapping.getKeyIndex() + 1) {
              try {
                // if(importAll) {
                parser.parseAll(table, rowData);
                // } else
                //	parser.parseEntry(table, parts);
              } catch (Exception ex) {
                logger.warn("Couldn't parse row from OpenCSV: " + lineCount);
              }
              globalCounter++;
            }
            lineCount++;
          }

        } else // Use the "old" method for splitting the lines.
        {
          String line;
          String[] parts = null;
          while ((line = bufRd.readLine()) != null) {
            /*
             * Ignore Empty & Commnet lines.
             */
            if ((commentChar != null) && line.startsWith(commentChar)) {
              // Do nothing
            } else if ((lineCount >= startLineNumber) && (line.trim().length() > 0)) {
              parts = line.split(delimiter);
              // If key dos not exists, ignore the line.
              if (parts.length >= mapping.getKeyIndex() + 1) {
                try {
                  // if(importAll) {
                  parser.parseAll(table, parts);
                  // } else
                  //	parser.parseEntry(table, parts);
                } catch (Exception ex) {
                  logger.warn("Couldn't parse row: " + lineCount);
                }
                globalCounter++;
              }
            }

            lineCount++;
          }
        }
      } finally {
        if (bufRd != null) {
          bufRd.close();
        }
      }
    } finally {
      if (is != null) {
        is.close();
      }
    }
  }