/** * Writes the XML Declaration and the opening RDF tag to the print Writer. Encoding attribute is * specified as the encoding argument. * * @param out PrintWriter * @throws IOException */ protected void writeHeader(OutputStreamWriter out) throws IOException { // validate if (out != null) { // wrapper for output stream writer (enable autoflushing) PrintWriter writer = new PrintWriter(out, true); // get encoding from the Encoding map String encoding = EncodingMap.getJava2IANAMapping(out.getEncoding()); // only insert encoding if there is a value if (encoding != null) { // print opening tags <?xml version="1.0" encoding=*encoding*?> writer.println("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>"); } else { // print opening tags <?xml version="1.0"?> writer.println("<?xml version=\"1.0\"?>"); } // print the Entities this.writeXMLEntities(writer); // print the opening RDF tag (including namespaces) this.writeRDFHeader(writer); } else { throw new IllegalArgumentException("Cannot write to null Writer."); } }