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;
    }

解决方案 »

  1.   

    public boolean saveCsvFile(String strFileName){
            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;
            }    }