Search in sources :

Example 1 with DoesNotExistException

use of org.apache.jena.shared.DoesNotExistException in project jena by apache.

the class JenaReader method read.

/**
     * Reads from url, using url as base, adding triples to model. 
     * Uses content negotiation to ask for application/rdf+xml, if available.
     * 
     * @param m
     *            A model to add triples to.
     * @param url
     *            The URL of the RDF/XML document.
     */
@Override
public void read(Model m, String url) throws JenaException {
    try {
        URLConnection conn = new URL(url).openConnection();
        conn.setRequestProperty("accept", "application/rdf+xml, application/xml; q=0.8, text/xml; q=0.7, application/rss+xml; q=0.3, */*; q=0.2");
        String encoding = conn.getContentEncoding();
        if (encoding == null)
            read(m, conn.getInputStream(), url);
        else
            read(m, new InputStreamReader(conn.getInputStream(), encoding), url);
    } catch (FileNotFoundException e) {
        throw new DoesNotExistException(url);
    } catch (IOException e) {
        throw new JenaException(e);
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) DoesNotExistException(org.apache.jena.shared.DoesNotExistException) InputStreamReader(java.io.InputStreamReader) FileNotFoundException(java.io.FileNotFoundException) WrappedIOException(org.apache.jena.shared.WrappedIOException) IOException(java.io.IOException) URLConnection(java.net.URLConnection) URL(java.net.URL)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 DoesNotExistException (org.apache.jena.shared.DoesNotExistException)1 JenaException (org.apache.jena.shared.JenaException)1 WrappedIOException (org.apache.jena.shared.WrappedIOException)1