title: How to save result of a sparql query on a .nt file
body: <p>I want to save all triples of <code>dbpedia</code> films on a N-Triple file (.nt file), I take a query on dbpedia endpoint with a java application and save the result on a file, but I can not read this file and take query from it! could u help me?</p>
  
  <p>//my code for save the result is here</p>
  
  <pre><code>try{
              FileWriter fostream = new FileWriter("C:\\Documents and Settings\\me\\Desktop\\DataSets\\dbpediafilmdataset.nt");
              BufferedWriter out = new BufferedWriter(fostream);
              String service ="http://dbpedia.org/sparql";
  
              String query = 
              "SELECT ?s ?p ?o " +
              "WHERE {" +
              " ?s &lt;http://dbpedia.org/property/wordnet_type&gt; &lt;http://www.w3.org/2006/03/wn/wn20/instances/synset-movie-noun-1&gt; ; ?p ?o "+
              "      } ";
  
              QueryExecution qexecctest = QueryExecutionFactory.sparqlService(service, query);
  
              try {
              ResultSet responseetest = qexecctest.execSelect();
  
              while( responseetest.hasNext()){
                  QuerySolution solnntest = responseetest.nextSolution();
                  RDFNode p = solnntest.get("?p");
                  RDFNode o = solnntest.get("?o");
                  RDFNode s = solnntest.get("?s");
                  String object="";
                  String triple="";
                  if (o.isLiteral()==true)
                  {
                      object="\"" + o.toString() + "\"";
                  }
                  else
                  object="&lt;" + o.toString() + "&gt;";
  
                  triple="&lt;" + s + "&gt;"+" " + "&lt;" + p + "&gt;" + " " + object + " " + "." ;
  
                  out.write(triple);
                  out.newLine();
  
                  }
              } finally {
              qexecctest.close();
              out.close();}
  
              }catch (Exception e){
                System.err.println("Error: " + e.getMessage());}
  </code></pre>
  
  <p>when I want to read the result file and take query from it, it gives some error like these:</p>
  
  <pre><code>com.hp.hpl.jena.rdf.model.impl.IStream.readChar(NTripleReader.java:485)
  com.hp.hpl.jena.rdf.model.impl.NTripleReader.unwrappedReadRDF(NTripleReader.java:140)
  com.hp.hpl.jena.rdf.model.impl.NTripleReader.readRDF(NTripleReader.java:120)
  com.hp.hpl.jena.rdf.model.impl.NTripleReader.read(NTripleReader.java:84)
  com.hp.hpl.jena.rdf.model.impl.NTripleReader.read(NTripleReader.java:72)
  com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:226)
  com.hp.hpl.jena.util.FileManager.readModelWorker(FileManager.java:395)
  com.hp.hpl.jena.util.FileManager.readModel(FileManager.java:335)
  com.hp.hpl.jena.util.FileManager.readModel(FileManager.java:319)
  ....
  </code></pre>