向NC发送XML的方法,回执总报,从输入流转换document出错:请检验文档格式。
我的代码是这样的。这file,xml文件手工导入到nc那是成功的,但通过代码推送过去就提示格式错误,求解!!!
急急急,哪位大神可以指点一下。。
private void sendMessage(HttpURLConnection connection, File file)
throws DocumentException {
try {
System.out.print("进入xml文件写入到输出流中!");
String path = file.getPath();
log.info("path:" + path);
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(new File(path));
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("UTF-8");
XMLWriter writer = new XMLWriter(connection.getOutputStream(),
format);
log.info(document.asXML());
writer.write(document);
writer.close();
} catch (IOException e) {
new IOException("传送失败", e);
}
} --------------------编程问答--------------------
沙发 --------------------编程问答-------------------- connection.getOutputStream()返回什么东西?
补充:Java , Web 开发