public static void main(String args[]) throws IOException { // Function References String path = "http://motherlode.ucar.edu:8081/thredds/radarServer/nexrad/level3/IDD/dataset.xml"; try { catURI = new URI(StringUtil2.escape(path, "/:-_.")); } catch (URISyntaxException e) { System.out.println("radarServer main: URISyntaxException=" + e.getMessage()); return; } // read the catalog System.out.println("radarServer main: full path=" + path); InputStream ios = null; try { URL url = new URL(path); ios = url.openStream(); // ios = new FileInputStream(path); // acat = factory.readXML(ios, catURI ); BufferedReader dataIS = new BufferedReader(new InputStreamReader(ios)); while (true) { String line = dataIS.readLine(); if (line == null) break; System.out.println(line); } } catch (Throwable t) { System.out.println("radarServer main: Exception on catalog=" + path + " " + t.getMessage()); return; } finally { if (ios != null) { try { ios.close(); } catch (IOException e) { System.out.println("radarServer main: error closing" + path); } } } return; }
/** * Does the actual work of reading a catalog. * * @param factory use this InvCatalogFactory * @param path reletive path starting from content root * @param catalogFullPath absolute location on disk * @return the InvCatalogImpl, or null if failure */ private InvCatalogImpl readCatalog( InvCatalogFactory factory, String path, String catalogFullPath) { InvCatalogImpl acat; try { catURI = new URI("file:" + StringUtil2.escape(catalogFullPath, "/:-_.")); // LOOK needed ? } catch (URISyntaxException e) { logServerStartup.info("radarServer readCatalog(): URISyntaxException=" + e.getMessage()); return null; } // read the catalog logServerStartup.info( "radarServer readCatalog(): full path=" + catalogFullPath + "; path=" + path); FileInputStream ios = null; try { ios = new FileInputStream(catalogFullPath); acat = factory.readXML(ios, catURI); } catch (Throwable t) { logServerStartup.error( "radarServer readCatalog(): Exception on catalog=" + catalogFullPath + " " + t.getMessage()); // +"\n log="+cat.getLog(), t); return null; } finally { if (ios != null) { try { ios.close(); } catch (IOException e) { logServerStartup.info("radarServer readCatalog(): error closing" + catalogFullPath); } } } return acat; }