Note that there are some explanatory texts on larger screens.

plurals
  1. PODownloading an XML/RDF file from a URL using Java
    primarykey
    data
    text
    <p>I am having trouble doing a simple download of an XML file from a URL. I have looked around this site for a while already and followed most of the examples on how to download a file with the proper encoding as far as I can tell, however I must be doing something wrong because I am not getting the desired output. At the moment my code looks like this. </p> <pre><code> Catalog cat = (Catalog)obj; String datasetURL = cat.getID()+"@datasets"; URL dataURL = new URL(datasetURL); InputStream iStream = dataURL.openStream(); int count = iStream.available(); char content[] = new char[count]; InputStreamReader isReader = new InputStreamReader(iStream,"UTF-8"); BufferedReader buffRead = new BufferedReader(isReader); buffRead.read(content, 0, count); String contentAsString = new String(content, 0,count); FileWriter fstream = new FileWriter("src/main/resources/datasets.xml"); BufferedWriter out = new BufferedWriter(fstream); out.write(contentAsString); out.close(); </code></pre> <p>This seems to work correctly however the xml file is displaying characters like: �Ksǵ���p� etc in Eclipse and appears as �Ksǵ���Žp� in notepad++. I dont know what to do because I have already added the encoding to the InputStreamReader so I thought that would solve this problem. </p> <p>Also I am not too familiar with RDF but the xml file has an RDF tag in it. Would that make any difference? </p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;r:RDF xmlns:s="http://www.w3.org/TR/1999/PR-rdf-schema-19990303#" xmlns:r="http://www.w3.org/1999/02/22-rdf-syntax-ns#" etc.. </code></pre> <p>Thanks much. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload