/** * Helper function to create DataMatrix. * * @param data InputStream * @return DataMatrix */ private DataMatrix getDataMatrix(InputStream data) throws Exception { // iterate over all lines in byte[] List<String> columnNames = null; List<LinkedList<String>> rowData = null; LineIterator it = IOUtils.lineIterator(data, null); try { int count = -1; while (it.hasNext()) { // first row is our column heading, create column vector if (++count == 0) { columnNames = new LinkedList(Arrays.asList(it.nextLine().split(Converter.VALUE_DELIMITER, -1))); } // all other rows are rows in the table else { rowData = (rowData == null) ? new LinkedList<LinkedList<String>>() : rowData; rowData.add( new LinkedList(Arrays.asList(it.nextLine().split(Converter.VALUE_DELIMITER, -1)))); } } } finally { LineIterator.closeQuietly(it); } // problem reading from data? if (columnNames == null || rowData == null) { if (LOG.isInfoEnabled()) { LOG.info( "getDataMatrix(), problem creating DataMatrix from file, data file probably missing data, returning null"); } return null; } // made it here, we can create DataMatrix if (LOG.isInfoEnabled()) { LOG.info("creating new DataMatrix(), from file data"); } // outta here return new DataMatrix(rowData, columnNames); }
/** * Reads the precomputed md5 digest out of a .md5 file (firehose). Assume the file only contains * one line wit checksum. * * @param file File * @return String * @throws Exception */ @Override public String getPrecomputedMD5Digest(File file) throws Exception { if (LOG.isInfoEnabled()) { LOG.info("getPrecomputedMD5Digest(): " + file.getCanonicalPath()); } String toReturn = ""; LineIterator it = org.apache.commons.io.FileUtils.lineIterator(file); try { while (it.hasNext()) { String content = it.nextLine(); if (content.split(" ").length == 2) { toReturn = content.split(" ")[0].toUpperCase(); } } } finally { LineIterator.closeQuietly(it); } // outta here return toReturn; }
public void next() { hasNext = it.next(); oneItRanges.clear(); oneItRanges.addAll(it.ranges); oneItY = it.y; }