XML : Passing a stringbuilder to a doc

I have the following code

  private void getdata(String stringfromDate,String stringtoDate ) throws IOException {  StringBuilder retVal = new StringBuilder();  URL oracle = new URL("https://xxxxxxxxxxxxxxxx" + stringfromDate +"&ToDate=" + stringtoDate +"" );  BufferedReader in = new BufferedReader(new InputStreamReader(oracle.openStream()));    String newLine = "\n";  String inputLine;  while ((inputLine = in.readLine()) != null) {              //System.out.println(inputLine);  retVal.append(inputLine).append(newLine);    }    in.close();    passSting(retVal);        }    private void passSting(StringBuilder retVal) {  Document doc = null;  try {  doc = loadXMLFromString(retVal.toString());//pull in the XML data into a new doc  System.out.println(doc);  } catch (Exception ex) {  Logger.getLogger(JavaApplication63.class.getName()).log(Level.SEVERE, null, ex);  }      }    public static org.w3c.dom.Document loadXMLFromString(String xml) throws Exception{  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();  DocumentBuilder builder = factory.newDocumentBuilder();  InputSource is = new InputSource(new StringReader(xml));  return builder.parse(is);  }       

I am passing through retVal to a method so that i can create a doc which can be read as an XML doc, however the doc value appears to be null what am i doing wrong? This is what i get in the console window [#document: null]

No comments:

Post a Comment