@Test public void testInput () throws IOException, DatasetBuilderException, InvalidDimensionTypeException { RawInput gzip = new GzipTsvInput (this.getClass ().getResource ("geo.gds.soft.txt.gz")); Parser p = new SuperCsvParserFactory ().parse (gzip.input ()); while(p.next ()) { } List<String> expectedRows = new ArrayList<String>(){ private static final long serialVersionUID = 1L; { add("1007_s_at"); add("1053_at"); add("117_at"); } }; assertFalse(p.next ()); assertThat(p.rowKeys (), is(expectedRows)); List<String> expectedColumns = Arrays.asList ("GSM564960\tGSM564961\tGSM564952\tGSM564958\tGSM564953\tGSM564959\tGSM564956\tGSM564957\tGSM564950\tGSM564954\tGSM564951\tGSM564955".split ("\t")); assertThat(p.columnKeys (), is(expectedColumns)); }
@Override public InputStream input () throws IOException { if (log.isDebugEnabled ()) log.debug (url); GZIPInputStream zis = null; BufferedOutputStream dest = null; BufferedInputStream bis = null; File unzipped = new TemporaryFile (); try { URLConnection urlc = url.openConnection (); zis = new GZIPInputStream (urlc.getInputStream ()); int count; byte data[] = new byte[BUFFER]; FileOutputStream fos = new FileOutputStream (unzipped); if (log.isDebugEnabled ()) log.debug ("Unzipping SOFT file to " + unzipped.getAbsolutePath ()); dest = new BufferedOutputStream (fos, BUFFER); while ((count = zis.read (data, 0, BUFFER)) != -1) { dest.write (data, 0, count); } dest.flush (); dest.close (); return new FileInputStream (unzipped); } finally { if (bis != null) { try { bis.close (); } catch (IOException ioe) {} } if (dest != null) { try { dest.close (); } catch (IOException ioe) {} } if (zis != null) { try { zis.close (); } catch (IOException ioe) {} } } }
GzipTsvInput extends AbstractRawInput { @Override public InputStream input () throws IOException { if (log.isDebugEnabled ()) log.debug (url); GZIPInputStream zis = null; BufferedOutputStream dest = null; BufferedInputStream bis = null; File unzipped = new TemporaryFile (); try { URLConnection urlc = url.openConnection (); zis = new GZIPInputStream (urlc.getInputStream ()); int count; byte data[] = new byte[BUFFER]; FileOutputStream fos = new FileOutputStream (unzipped); if (log.isDebugEnabled ()) log.debug ("Unzipping SOFT file to " + unzipped.getAbsolutePath ()); dest = new BufferedOutputStream (fos, BUFFER); while ((count = zis.read (data, 0, BUFFER)) != -1) { dest.write (data, 0, count); } dest.flush (); dest.close (); return new FileInputStream (unzipped); } finally { if (bis != null) { try { bis.close (); } catch (IOException ioe) {} } if (dest != null) { try { dest.close (); } catch (IOException ioe) {} } if (zis != null) { try { zis.close (); } catch (IOException ioe) {} } } } }
GzipTsvInput extends AbstractRawInput { @Override public InputStream input () throws IOException { if (log.isDebugEnabled ()) log.debug (url); GZIPInputStream zis = null; BufferedOutputStream dest = null; BufferedInputStream bis = null; File unzipped = new TemporaryFile (); try { URLConnection urlc = url.openConnection (); zis = new GZIPInputStream (urlc.getInputStream ()); int count; byte data[] = new byte[BUFFER]; FileOutputStream fos = new FileOutputStream (unzipped); if (log.isDebugEnabled ()) log.debug ("Unzipping SOFT file to " + unzipped.getAbsolutePath ()); dest = new BufferedOutputStream (fos, BUFFER); while ((count = zis.read (data, 0, BUFFER)) != -1) { dest.write (data, 0, count); } dest.flush (); dest.close (); return new FileInputStream (unzipped); } finally { if (bis != null) { try { bis.close (); } catch (IOException ioe) {} } if (dest != null) { try { dest.close (); } catch (IOException ioe) {} } if (zis != null) { try { zis.close (); } catch (IOException ioe) {} } } } GzipTsvInput(URL url); }
GzipTsvInput extends AbstractRawInput { @Override public InputStream input () throws IOException { if (log.isDebugEnabled ()) log.debug (url); GZIPInputStream zis = null; BufferedOutputStream dest = null; BufferedInputStream bis = null; File unzipped = new TemporaryFile (); try { URLConnection urlc = url.openConnection (); zis = new GZIPInputStream (urlc.getInputStream ()); int count; byte data[] = new byte[BUFFER]; FileOutputStream fos = new FileOutputStream (unzipped); if (log.isDebugEnabled ()) log.debug ("Unzipping SOFT file to " + unzipped.getAbsolutePath ()); dest = new BufferedOutputStream (fos, BUFFER); while ((count = zis.read (data, 0, BUFFER)) != -1) { dest.write (data, 0, count); } dest.flush (); dest.close (); return new FileInputStream (unzipped); } finally { if (bis != null) { try { bis.close (); } catch (IOException ioe) {} } if (dest != null) { try { dest.close (); } catch (IOException ioe) {} } if (zis != null) { try { zis.close (); } catch (IOException ioe) {} } } } GzipTsvInput(URL url); @Override String contentType(); @Override String name(); @Override InputStream input(); @Override long size(); }
GzipTsvInput extends AbstractRawInput { @Override public InputStream input () throws IOException { if (log.isDebugEnabled ()) log.debug (url); GZIPInputStream zis = null; BufferedOutputStream dest = null; BufferedInputStream bis = null; File unzipped = new TemporaryFile (); try { URLConnection urlc = url.openConnection (); zis = new GZIPInputStream (urlc.getInputStream ()); int count; byte data[] = new byte[BUFFER]; FileOutputStream fos = new FileOutputStream (unzipped); if (log.isDebugEnabled ()) log.debug ("Unzipping SOFT file to " + unzipped.getAbsolutePath ()); dest = new BufferedOutputStream (fos, BUFFER); while ((count = zis.read (data, 0, BUFFER)) != -1) { dest.write (data, 0, count); } dest.flush (); dest.close (); return new FileInputStream (unzipped); } finally { if (bis != null) { try { bis.close (); } catch (IOException ioe) {} } if (dest != null) { try { dest.close (); } catch (IOException ioe) {} } if (zis != null) { try { zis.close (); } catch (IOException ioe) {} } } } GzipTsvInput(URL url); @Override String contentType(); @Override String name(); @Override InputStream input(); @Override long size();  }