亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? xmlwriter.java

?? 解觖java技術中后臺無法上傳數給的情況
?? JAVA
字號:
/*
 * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/admin/importexport/XMLWriter.java,v 1.6 2006/04/14 17:36:29 minhnn Exp $
 * $Author: minhnn $
 * $Revision: 1.6 $
 * $Date: 2006/04/14 17:36:29 $
 *
 * ====================================================================
 *
 * Copyright (C) 2002-2006 by MyVietnam.net
 *
 * All copyright notices regarding mvnForum MUST remain 
 * intact in the scripts and in the outputted HTML.
 * The "powered by" text/logo with a link back to
 * http://www.mvnForum.com and http://www.MyVietnam.net in 
 * the footer of the pages MUST remain visible when the pages
 * are viewed on the internet or intranet.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Support can be obtained from support forums at:
 * http://www.mvnForum.com/mvnforum/index
 *
 * Correspondence and Marketing Questions can be sent to:
 * info at MyVietnam net
 *
 * @author: Igor Manic   
 */
package com.mvnforum.admin.importexport;

import java.io.*;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.myvietnam.mvncore.exception.ExportException;

/**
 * @author Igor Manic
 * @version $Revision: 1.6 $, $Date: 2006/04/14 17:36:29 $
 * <br/>
 * <code>XMLWriter</code> class encapsulates methods for creating and writing
 * data to XML files with automatic indentation and special characters encoding.
 */
public class XMLWriter {

    /** Message log. */
    private static Log log = LogFactory.getLog(XMLWriter.class);

    private static String lineSeparator=System.getProperty("line.separator", "\n");
    private StringBuffer textBuffer;
    private int indentLevel=0; //current XML element level
    private String indentString=""; //indent string for each next level of XML output
    private OutputStreamWriter outWriter=null;
    private boolean startedNewElement=false;

    private XMLWriter() {
        super();
        textBuffer=null;
        indentLevel=0; indentString="";
        outWriter=null;
        startedNewElement=false;
    }

    public XMLWriter(String indentString, OutputStreamWriter outWriter) {
        this();
        this.indentString=indentString;
        this.outWriter=outWriter;
    }

    public XMLWriter(String indentString, File outputFile)
    throws ExportException {
        this();
        this.indentString=indentString;
        log.debug("Setting output to file \""+outputFile.getAbsolutePath()+"\"");
        if (!outputFile.exists())
            try {
                outputFile.createNewFile();
            } catch (IOException e) {
                log.error("XML output could not be created.");
                throw new ExportException("Error on server: "+
                      "Can't make XML output file.", e);
            }
        else if (!outputFile.isFile()) {
            log.error("XML output is not a file (it's probably directory).");
            throw new ExportException("Error on server: "+
                  "XML output is not a file (it's probably directory).");
        }
        if (!outputFile.canWrite()) {
            log.error("XML output file can't be written to.");
            throw new ExportException("Error on server: "+
                  "XML output file can't be written to.");
        } else {
            try {
                java.io.OutputStream outStream=new FileOutputStream(outputFile);
                this.outWriter=new OutputStreamWriter(outStream, "UTF8");
            } catch (FileNotFoundException e) {
                log.error("XML output file can't be found.");
                throw new ExportException("Error on server: "+
                      "XML output file can't be found.", e);
            } catch (UnsupportedEncodingException e) {
                log.error("UTF8 is unsupported encoding for XML output.");
                throw new ExportException("Error on server: "+
                      "Can't make XML output file.", e);
            }
        }
    }

    public XMLWriter(String indentString, String fileName)
    throws ExportException {
        this(indentString, new File(fileName));
    }


    public void close() throws IOException {
        outputFlush();
        if (outWriter!=null) outWriter.close();
    }

    public void startDocument(String dtdschemaDecl) throws IOException {
        String xmlDecl="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
        startedNewElement=false;
        outputText(xmlDecl); outputNewLine();
        outputText(dtdschemaDecl); outputNewLine();
    }

    public void endDocument() throws IOException {
        processBufferedData();
        outputNewLine();
        outputFlush();
    }

    public void startElement(String elementName)
    throws IOException {
        startElement(elementName, null);
    }

    public void startElement(String elementName, String[] attrNameValue)
    throws IOException {
        processBufferedData();
        outputNewLine();
        outputText("<"+elementName);
        if (attrNameValue!=null) for (int i=0; i<attrNameValue.length-1; i+=2) {
            String attrName=attrNameValue[i];
            String attrValue=attrNameValue[i+1];
            outputText(" ");
            outputText(attrName+"=\""+attrValue+"\"");
        }
        outputText(">");
        indentLevel++;
        //outputNewLine();
        startedNewElement=true;
    }

    public void endElement(String elementName)
    throws IOException {
        processBufferedData();
        indentLevel--;
        if (!startedNewElement) outputNewLine();
        outputText("</"+elementName+">");
        //outputNewLine();
        startedNewElement=false;
    }


    public void writeNewLine() throws IOException {
        outputNewLine();
    }

    public void writeComment(String comment) throws IOException {
        processBufferedData();
        /*if (startedNewElement)*/ outputNewLine();
        outputText("<!-- "+comment+" -->");
        //startedNewElement=false; I should leave this variable, otherwise, if
        //I have more comments one behind another, they'll all be output in
        //one row, one to another, which is bad
    }

    public void writeData(String data) throws IOException {
        if (textBuffer==null) {
            textBuffer=new StringBuffer(data);
        } else {
            textBuffer.append(data);
        }
    }

    public void encodeAndWriteData(String data) throws IOException {
        //we should encode all '<' and '&'
        int amp=data.indexOf('&');
        int lt=data.indexOf('<');
        int i=-1;
        if ((amp>=0) && (lt>=0))  i=(amp<lt)?amp:lt;
        else if (amp>=0) i=amp;
        else i=lt;
        while ((i<data.length()) && (i>=0)) {
            if (i==amp) {
                data=data.substring(0, i)+"&amp;"+data.substring(i+1);
                amp=data.indexOf('&', i+4);
                lt=data.indexOf('<', i+4);
                i+=4; //it should be 5, but nevermind
            } else if (i==lt) {
                data=data.substring(0, i)+"&lt;"+data.substring(i+1);
                amp=data.indexOf('&', i+3);
                lt=data.indexOf('<', i+3);
                i+=3; //it should be 5, but nevermind
            } else {
                log.error("processBufferedRawText(): i=="+i+
                          " is different than both amp=="+amp+" and lt=="+lt+"?!");
                i++;
                amp=data.indexOf('&', i);
                lt=data.indexOf('<', i);
            }
            if ((amp>=0) && (lt>=0))  i=(amp<lt)?amp:lt;
            else if (amp>=0) i=amp;
            else i=lt;
        }

        writeData(data);
    }



// ========================================================
// =================== RAW TEXT OUTPUT ====================
// ========================================================

    private void processBufferedData() throws IOException {
        if (textBuffer==null) return;
        String s=""+textBuffer;
        if (!s.trim().equals("")) textBuffer=null;
        if (s.equals("")) return;

        if (startedNewElement) outputNewLine();
        startedNewElement=false;
        String padding="";
        for (int i=0; i<indentLevel; i++) padding=padding+indentString;
        int pos=s.indexOf(lineSeparator);
        while ((pos<s.length()) && (pos>=0)) {
            s=s.substring(0, pos)+
              lineSeparator+ padding+
              s.substring(pos+lineSeparator.length());
            pos=s.indexOf(lineSeparator, pos+lineSeparator.length());
        }
        outputText(s);
    }

    private void outputText(String s) throws IOException {
        if (outWriter==null) {
            log.error("outputText(): outWriter==null.");
        } else {
            outWriter.write(s);
        }
    }

    private void outputFlush() throws IOException {
        if (outWriter==null) {
            log.error("outputFlush(): outWriter==null.");
        } else {
            outWriter.flush();
        }
    }

    private void outputNewLine() throws IOException {
        if (outWriter==null) {
            log.error("outputNewLine(): outWriter==null.");
        } else {
            outWriter.write(lineSeparator);
            for (int i=0; i<indentLevel; i++) outWriter.write(indentString);
        }
    }


}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲大尺度视频在线观看| 国产日本一区二区| 蜜桃视频在线观看一区| 日韩欧美一区中文| 久久精品久久久精品美女| 日韩精品在线一区二区| 国产精品18久久久久久vr| 亚洲国产精品成人久久综合一区| 丁香天五香天堂综合| 椎名由奈av一区二区三区| 在线观看视频一区二区| 免费观看一级欧美片| 国产亚洲一本大道中文在线| 成人成人成人在线视频| 亚洲一级二级三级| 日韩一二三区视频| 国产成人综合网站| 亚洲综合色婷婷| 精品国产一区二区三区不卡| 国内成人自拍视频| 中文字幕一区三区| 69p69国产精品| 国产91丝袜在线18| 丝袜美腿亚洲综合| 日本一区免费视频| 欧美丰满少妇xxxxx高潮对白| 美美哒免费高清在线观看视频一区二区| 精品不卡在线视频| 色噜噜狠狠色综合中国| 麻豆传媒一区二区三区| 中文字幕一区二区三区在线观看 | 亚洲成人在线免费| 久久免费看少妇高潮| 在线影视一区二区三区| 国产一区二区三区综合| 亚洲精品五月天| 精品国产第一区二区三区观看体验| 91女厕偷拍女厕偷拍高清| 日本va欧美va精品| 亚洲欧洲中文日韩久久av乱码| 91精品国产一区二区| 91麻豆高清视频| 国产精品夜夜嗨| 日韩高清不卡一区| 亚洲人123区| 欧美激情在线看| 日韩欧美在线123| 欧美视频一区在线| 99久免费精品视频在线观看| 韩国一区二区三区| 日韩精品欧美成人高清一区二区| 中文字幕日韩一区| 久久免费视频一区| 欧美一区二区三区思思人 | 91麻豆国产香蕉久久精品| 精品一区二区三区的国产在线播放| 一区二区三区电影在线播| 久久男人中文字幕资源站| 欧美乱妇一区二区三区不卡视频| 一本到不卡精品视频在线观看| 经典三级一区二区| 久久精品国产成人一区二区三区| 亚洲综合小说图片| 成人欧美一区二区三区在线播放| 久久久久久一二三区| 欧美成人综合网站| 91麻豆精品国产| 欧美性色aⅴ视频一区日韩精品| 成人18视频在线播放| 国产福利精品导航| 国产美女av一区二区三区| 久久er99精品| 国产在线国偷精品免费看| 久久99精品国产麻豆婷婷| 欧美aaa在线| 蜜桃视频免费观看一区| 日本欧美大码aⅴ在线播放| 三级欧美在线一区| 日本成人在线电影网| 日韩精品电影一区亚洲| 日韩精彩视频在线观看| 爽好久久久欧美精品| 日韩成人一级大片| 男女男精品视频网| 亚洲免费观看高清| 亚洲亚洲精品在线观看| 精品在线视频一区| 国产麻豆视频一区| 国产91精品精华液一区二区三区| 国产91在线观看丝袜| 不卡的电影网站| 91亚洲国产成人精品一区二三| 成人爱爱电影网址| 91福利在线免费观看| 欧美日韩国产综合一区二区| 欧美一区二区女人| 亚洲精品一区在线观看| 国产日韩欧美a| 中文字幕佐山爱一区二区免费| 伊人色综合久久天天人手人婷| 亚洲成人动漫av| 美女视频第一区二区三区免费观看网站| 麻豆免费精品视频| gogo大胆日本视频一区| 精品视频免费看| 久久影视一区二区| 日韩理论片一区二区| 亚洲成人免费视频| 亚洲图片一区二区| 日本免费在线视频不卡一不卡二| 精品一区二区av| www..com久久爱| 91精品午夜视频| 国产精品丝袜黑色高跟| 亚洲精品日韩专区silk| 美国毛片一区二区三区| 99免费精品在线| 91网址在线看| 另类小说综合欧美亚洲| 午夜视频久久久久久| 国模冰冰炮一区二区| 色哟哟国产精品| 欧美一区二区三区喷汁尤物| 国产精品久久久久影院亚瑟| 亚洲免费av观看| 成人美女在线视频| 日韩丝袜美女视频| 亚洲另类一区二区| 国产精品99久久久久久久女警| 99re这里只有精品视频首页| 久久综合九色综合97婷婷| 亚洲少妇中出一区| 欧美aaaaaa午夜精品| 91福利社在线观看| 精品国产一区二区三区av性色| 亚洲视频香蕉人妖| av亚洲精华国产精华精华| 精品国产亚洲在线| 亚洲一区中文日韩| 色香蕉成人二区免费| 国产喂奶挤奶一区二区三区| 日本亚洲免费观看| 91黄色在线观看| 亚洲免费观看视频| 久久99久久久欧美国产| 久久这里只精品最新地址| 麻豆精品久久精品色综合| 91久久免费观看| 99精品视频免费在线观看| 欧美高清在线一区| 国产色一区二区| 国产精品久久久久aaaa| 国产精品女同一区二区三区| 日本sm残虐另类| 99久久精品国产毛片| 久久综合九色综合97婷婷女人 | 精品久久久久久久久久久院品网| 中文一区二区在线观看| 99精品视频在线观看| 欧美精品一二三四| 亚洲综合丝袜美腿| 欧美日韩在线亚洲一区蜜芽| 久久久精品蜜桃| 国产成人免费视频网站| 国产亚洲欧美一级| 久久精品理论片| 久久一夜天堂av一区二区三区| 国产一区二区精品在线观看| 91老师国产黑色丝袜在线| 亚洲视频每日更新| 日韩欧美国产电影| 日韩午夜激情av| 久久久久国产精品厨房| 国产精品久久三| 美女mm1313爽爽久久久蜜臀| 欧美日韩一区二区不卡| 亚洲大型综合色站| 91黄色在线观看| 亚洲综合在线第一页| 日本精品一级二级| 丝袜a∨在线一区二区三区不卡 | 亚洲一区二区三区视频在线| 91免费观看国产| 亚洲啪啪综合av一区二区三区| 91福利在线看| 亚洲一区二区黄色| 精品视频免费在线| 亚洲第一电影网| 欧美mv日韩mv国产网站app| 看国产成人h片视频| 精品国产髙清在线看国产毛片| 国产黄色精品视频| 国产精品久久久久久久蜜臀| 91麻豆.com| 午夜精品123| 日本一区二区免费在线观看视频| 丁香婷婷综合色啪| 一区二区三区丝袜| 91麻豆精品91久久久久久清纯 | 日本中文字幕不卡|