public boolean saveXml(Node node) {
getError().clear(); Transformer serializer = null;
File fXml = new File(m_strXmlFileName);
// XMLファイルを格納する
try{
TransformerFactory factory = TransformerFactory.newInstance();
serializer = factory.newTransformer();
Properties props = new Properties();
// ファイルクラス型を設定する
props.put(OutputKeys.METHOD, getMethod());
// コードを設定する
props.put(OutputKeys.ENCODING, getEncoding());
//インデントを設定する
props.put(OutputKeys.INDENT, "yes");
props.put(XALAN_INDENT_AMOUNT, "4");
//バージョンを設定する
props.put(OutputKeys.VERSION, getVersion());
serializer.setOutputProperties(props);
Document doc = getDocument(node);
Source source = new DOMSource(doc);
Result result = null ;
if(nType == TYPE_DEFAULT){
FileWriter writer = new FileWriter(fXml);
result = new StreamResult(writer);
if (result != null) {
serializer.transform(source, result);
}
writer.close() ;
}
else if(nType == TYPE_SVG){
result = new StreamResult(fXml);
if (result != null) {
serializer.transform(source, result);
}
}
}
// システムエラー
catch(TransformerConfigurationException tce){
tce.printStackTrace();
return false;
}
// ファイル格納際のエラー、例えば書き込む権利がない等
catch(Exception te){
getError().setError_FileOpen(m_strXmlFileName, te.getMessage());
return false;
} return true;
}
getError().clear(); Transformer serializer = null;
File fXml = new File(m_strXmlFileName);
// XMLファイルを格納する
try{
TransformerFactory factory = TransformerFactory.newInstance();
serializer = factory.newTransformer();
Properties props = new Properties();
// ファイルクラス型を設定する
props.put(OutputKeys.METHOD, getMethod());
// コードを設定する
props.put(OutputKeys.ENCODING, getEncoding());
//インデントを設定する
props.put(OutputKeys.INDENT, "yes");
props.put(XALAN_INDENT_AMOUNT, "4");
//バージョンを設定する
props.put(OutputKeys.VERSION, getVersion());
serializer.setOutputProperties(props);
Document doc = getDocument(node);
Source source = new DOMSource(doc);
Result result = null ;
if(nType == TYPE_DEFAULT){
FileWriter writer = new FileWriter(fXml);
result = new StreamResult(writer);
if (result != null) {
serializer.transform(source, result);
}
writer.close() ;
}
else if(nType == TYPE_SVG){
result = new StreamResult(fXml);
if (result != null) {
serializer.transform(source, result);
}
}
}
// システムエラー
catch(TransformerConfigurationException tce){
tce.printStackTrace();
return false;
}
// ファイル格納際のエラー、例えば書き込む権利がない等
catch(Exception te){
getError().setError_FileOpen(m_strXmlFileName, te.getMessage());
return false;
} return true;
}
解决方案 »
- 大家帮帮忙,谢谢了
- birt frameset toolbar 设置
- JS转发问题!!
- 监听 使用的几个问题?盼解答....谢哦
- 关于登陆表单处理!急!
- 散分!
- 请问:我把html的文件改为.jsp时,为什么再调用的时候,界面中的文字都变成了乱码。谢谢
- 将String转化成double怎么转换?
- servlet接收到的参数是String型的吗?
- 我是JSP的初学者。谢谢你们的指点。请问。。。。
- 自定义标签Tomcat和J2ee正常,在WebLogic中却报错!cannot resolve symbol:variable EVAL_BODY_BUFFERED
- 关于文件查找的问题,高分相送!!!!!!
try{
FileOutputStream fileOutput = new FileOutputStream(strFileName);
PrintWriter out = new PrintWriter(fileOutput, true);
for(int i = 0 ; i < csvFileList.size() ; i++){
out.println((String)csvFileList.get(i)) ;
}
fileOutput.close() ;
out.close() ;
csvFileList.clear() ;
return true ;
}
catch(IOException e){
String strErr = e.toString();
PcedDefFileInf pcedDefFileInf = new PcedDefFileInf();
String strErrMsg = pcedDefFileInf.getMessage(PcedMsgMap.ID_100001) ;
this.getError().setErrMsg(
pcedDefFileInf.replaceMessage(strErrMsg,strFileName));
this.getError().addDetailBefore(strErr);
return false;
} }