@Test public void testReadNexradTableAsStream() throws IOException { Class<?> c = TableParser.class; InputStream is = c.getResourceAsStream(fromResource); List<TableParser.Record> recs = TableParser.readTable(is, "3,15,54,60d,67d,73d", 50000); TableParser.Record rec = recs.get(0); Assert.assertEquals("TLX", rec.get(0)); Assert.assertEquals(" 000001", rec.get(1)); Assert.assertEquals(" OKLAHOMA_CITY/Norman OK US", rec.get(2)); Assert.assertEquals(3532.0, (Double) rec.get(3), 0.1); Assert.assertEquals(-9727.0, (Double) rec.get(4), 0.1); Assert.assertEquals(370.0, (Double) rec.get(5), 0.1); rec = recs.get(20); Assert.assertEquals("TWX", rec.get(0)); Assert.assertEquals(" 000554", rec.get(1)); Assert.assertEquals(" TOPEKA/Alma KS US", rec.get(2)); Assert.assertEquals(3898.0, (Double) rec.get(3), 0.1); Assert.assertEquals(-9622.0, (Double) rec.get(4), 0.1); Assert.assertEquals(417.0, (Double) rec.get(5), 0.1); }
public static List<Record> readTable(String urlString, String format, int maxLines) throws IOException, NumberFormatException { InputStream ios; if (urlString.startsWith("http:")) { URL url = new URL(urlString); ios = url.openStream(); } else { ios = new FileInputStream(urlString); } return readTable(ios, format, maxLines); }
TableParser { public static List<Record> readTable(String urlString, String format, int maxLines) throws IOException, NumberFormatException { InputStream ios; if (urlString.startsWith("http:")) { URL url = new URL(urlString); ios = url.openStream(); } else { ios = new FileInputStream(urlString); } return readTable(ios, format, maxLines); } }
TableParser { public static List<Record> readTable(String urlString, String format, int maxLines) throws IOException, NumberFormatException { InputStream ios; if (urlString.startsWith("http:")) { URL url = new URL(urlString); ios = url.openStream(); } else { ios = new FileInputStream(urlString); } return readTable(ios, format, maxLines); } TableParser(String format); }
TableParser { public static List<Record> readTable(String urlString, String format, int maxLines) throws IOException, NumberFormatException { InputStream ios; if (urlString.startsWith("http:")) { URL url = new URL(urlString); ios = url.openStream(); } else { ios = new FileInputStream(urlString); } return readTable(ios, format, maxLines); } TableParser(String format); static List<Record> readTable(String urlString, String format, int maxLines); static List<Record> readTable(InputStream ios, String format, int maxLines); void setComment(String comment); List<Record> readAllRecords(InputStream ios, int maxLines); Field getField(int fldno); int getNumberOfFields(); DerivedField addDerivedField(Field from, Transform transform, Class type); }
TableParser { public static List<Record> readTable(String urlString, String format, int maxLines) throws IOException, NumberFormatException { InputStream ios; if (urlString.startsWith("http:")) { URL url = new URL(urlString); ios = url.openStream(); } else { ios = new FileInputStream(urlString); } return readTable(ios, format, maxLines); } TableParser(String format); static List<Record> readTable(String urlString, String format, int maxLines); static List<Record> readTable(InputStream ios, String format, int maxLines); void setComment(String comment); List<Record> readAllRecords(InputStream ios, int maxLines); Field getField(int fldno); int getNumberOfFields(); DerivedField addDerivedField(Field from, Transform transform, Class type);  }