@Override public Model read( String url, String base, String lang ) { try ( InputStream is = new URL( url ) .openStream() ) { read( is, base, lang ); } catch (IOException e) { throw new WrappedIOException( e ); } return this; }
/** Answer the list of rules loaded from the given filename. May throw a ReasonerException wrapping an IOException. */ public static List<Rule> loadRules( String fileName ) { try { return Rule.parseRules(Util.loadRuleParserFromResourceFile( fileName ) ); } catch (WrappedIOException e) { throw new ReasonerException("Can't load rules file: " + fileName, e.getCause() ); } }
/** Answer the list of rules loaded from the given filename. May throw a ReasonerException wrapping an IOException. */ public static List<Rule> loadRules( String fileName ) { try { return Rule.parseRules(Util.loadRuleParserFromResourceFile( fileName ) ); } catch (WrappedIOException e) { throw new ReasonerException("Can't load rules file: " + fileName, e.getCause() ); } }
public static BufferedReader readerFromURL( String urlStr ) { try { return asBufferedUTF8( new URL(urlStr).openStream() ); } catch (java.net.MalformedURLException e) { // Try as a plain filename. try { return asBufferedUTF8( new FileInputStream( urlStr ) ); } catch (FileNotFoundException f) { throw new WrappedIOException( f ); } } catch (IOException e) { throw new WrappedIOException( e ); } }
grr.setRules(Rule.parseRules(Util.loadRuleParserFromResourceFile("etc/expt.rules"))); } catch (WrappedIOException e) { System.out.println("Failed to open rules file: " + e.getCause() ); System.exit(1); reasoner = new FBRuleReasoner(rules); } catch (WrappedIOException e) { System.out.println("Failed to open rules file: " + e.getCause()); System.exit(1);
@Override public Model read( String url, String base, String lang ) { try ( InputStream is = new URL( url ) .openStream() ) { read( is, base, lang ); } catch (IOException e) { throw new WrappedIOException( e ); } return this; }
grr.setRules(Rule.parseRules(Util.loadRuleParserFromResourceFile("etc/expt.rules"))); } catch (WrappedIOException e) { System.out.println("Failed to open rules file: " + e.getCause() ); System.exit(1); reasoner = new FBRuleReasoner(rules); } catch (WrappedIOException e) { System.out.println("Failed to open rules file: " + e.getCause()); System.exit(1);
public static BufferedReader readerFromURL( String urlStr ) { try { return asBufferedUTF8( new URL(urlStr).openStream() ); } catch (java.net.MalformedURLException e) { // Try as a plain filename. try { return asBufferedUTF8( new FileInputStream( urlStr ) ); } catch (FileNotFoundException f) { throw new WrappedIOException( f ); } } catch (IOException e) { throw new WrappedIOException( e ); } }
/** Slurp up a whole file */ public String readWholeFileAsUTF8(InputStream in) { try (Reader r = FileUtils.asBufferedUTF8(in); StringWriter sw = new StringWriter(1024)) { char buff[] = new char[1024] ; while (true) { int l = r.read(buff) ; if ( l <= 0 ) break ; sw.write(buff, 0, l) ; } return sw.toString() ; } catch (IOException ex) { throw new WrappedIOException(ex) ; } }
/** Answer a BufferedReader than reads from the named resource file as UTF-8, possibly throwing WrappedIOExceptions. */ public static BufferedReader openResourceFile( String filename ) { try { InputStream is = FileUtils.openResourceFileAsStream( filename ); return new BufferedReader(new InputStreamReader(is, "UTF-8")); } catch (IOException e) { throw new WrappedIOException( e ); } }
/** Answer a BufferedReader than reads from the named resource file as UTF-8, possibly throwing WrappedIOExceptions. */ public static BufferedReader openResourceFile( String filename ) { try { InputStream is = FileUtils.openResourceFileAsStream( filename ); return new BufferedReader(new InputStreamReader(is, "UTF-8")); } catch (IOException e) { throw new WrappedIOException( e ); } }
/** Slurp up a whole file */ public String readWholeFileAsUTF8(InputStream in) { try (Reader r = FileUtils.asBufferedUTF8(in); StringWriter sw = new StringWriter(1024)) { char buff[] = new char[1024] ; while (true) { int l = r.read(buff) ; if ( l <= 0 ) break ; sw.write(buff, 0, l) ; } return sw.toString() ; } catch (IOException ex) { throw new WrappedIOException(ex) ; } }
@Override public Model read(String url, String base, String lang) { try { InputStream is = new URL(url).openStream(); try { read(is, base, lang); } finally { if (null != is) { is.close(); } } } catch (IOException e) { throw new WrappedIOException(e); } return this; }
@Override public Model read(String url, String base, String lang) { try { InputStream is = new URL(url).openStream(); try { read(is, base, lang); } finally { if (null != is) { is.close(); } } } catch (IOException e) { throw new WrappedIOException(e); } return this; }
@Override public SecuredModel read(final String url, final String base, final String lang) throws ReadDeniedException, AuthenticationRequiredException { try (InputStream is = new URL(url).openStream()) { read(is, base, lang); } catch (final IOException e) { throw new WrappedIOException(e); } return holder.getSecuredItem(); }
{ throw new WrappedIOException( e ); }
{ throw new WrappedIOException( e ); }
synchronized private void read(final Graph g, InputSource inputS, String xmlBase, Model m) { try { g.getEventManager().notifyEvent(g, GraphEvents.startRead); inputS.setSystemId(xmlBase); handler = new JenaHandler(g, m, errorHandler); handler.useWith(arpf.getHandlers()); arpf.parse(inputS, xmlBase); } catch (IOException e) { throw new WrappedIOException(e); } catch (SAXException e) { throw new JenaException(e); } finally { g.getEventManager().notifyEvent(g, GraphEvents.finishRead); handler = null; } }
synchronized private void read(final Graph g, InputSource inputS, String xmlBase, Model m) { try { g.getEventManager().notifyEvent(g, GraphEvents.startRead); inputS.setSystemId(xmlBase); handler = new JenaHandler(g, m, errorHandler); handler.useWith(arpf.getHandlers()); arpf.parse(inputS, xmlBase); } catch (IOException e) { throw new WrappedIOException(e); } catch (SAXException e) { throw new JenaException(e); } finally { g.getEventManager().notifyEvent(g, GraphEvents.finishRead); handler = null; } }