91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 502KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-07
  • 語言: Java
  • 標簽: csv??xml??java??

資源簡介

java實現csv 轉 xml,內含3種 方法

資源截圖

代碼片段和文件信息

package?com.test;
import?java.io.BufferedReader;
import?java.io.File;
import?java.io.FileReader;
import?java.io.FileWriter;
import?java.io.IOException;
import?java.io.InputStream;
import?java.io.InputStreamReader;
import?java.io.LineNumberReader;
import?java.io.UnsupportedEncodingException;
import?java.util.ArrayList;
import?java.util.List;

import?com.opencsv.CSVReader;
import?com.thoughtworks.xstream.XStream;
/**
?*?
?*?use?java?bean?to?generate?xml.
?*?Need?to?call?below?classes:
?*?TreeNode。java
?*?TreeUtil。java
?*
?*/
public?class?CsvToxml1?{
????public?static?void?main(String?args[]){
????????System.out.println(“start...“);??????
????????String?inputFile?=?“F:/temp/workspace/helloWord/data.csv“;
????????String?outFile?=?“F:/temp/workspace/helloWord/output/data1.xml“;
????????try?{
???????? ??BufferedReader?reader?=?null;??
???????? ?reader?=?new?BufferedReader(new?FileReader(inputFile));
????????????String?line?=?““;
????????????List?treeNodeList?=?new?ArrayList();
????????????while((line=reader.readLine())!=null){?
???????????? ?String?data[]?=?line.split(““);
???????????? ?TreeNode?treeNode?=?new?TreeNode();??
???????????? ?treeNode.setColumn1(data[0]);
???????????? ?treeNode.setColumn2(data[1]);??
???????????????//??System.out.println(data[0]+““+data[1]);
?????????????????treeNodeList.add(treeNode);
????????????}
????????????
???????????? ????String?xmlFile?=?new?TreeUtil().parseNodeToxml(treeNodeList);????????????
???????????? ????FileWriter?writer?=?new?FileWriter(outFile);????????????
???????????? ????writer.write(xmlFile);
???????????? ????writer.flush();
???????????? ????writer.close();
????????????
????????????System.out.println(“completed...“);
????????}?catch?(Exception?e)?{
????????????//?TODO?Auto-generated?catch?block
????????????e.printStackTrace();
????????}
????}
????
???
??
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????479??2017-02-09?23:54??helloWord\.classpath

?????文件????????385??2017-02-09?21:53??helloWord\.project

?????文件????????598??2017-02-09?21:53??helloWord\.settings\org.eclipse.jdt.core.prefs

?????文件???????2013??2017-02-10?07:32??helloWord\bin\com\test\CsvToxml1.class

?????文件???????1934??2017-02-10?00:31??helloWord\bin\com\test\CsvToxml2.class

?????文件???????2721??2017-02-10?07:33??helloWord\bin\com\test\CsvToxml3.class

?????文件????????910??2017-02-09?23:54??helloWord\bin\com\test\TreeNode.class

?????文件???????1415??2017-02-10?00:26??helloWord\bin\com\test\TreeUtil.class

?????文件?????????47??2017-02-09?21:59??helloWord\data.csv

?????文件??????80720??2017-02-09?21:55??helloWord\lib\opencsv-3.9.jar

?????文件???????6073??2017-02-09?23:54??helloWord\lib\xmlpull_1_0_5.jar

?????文件?????492719??2017-02-09?21:55??helloWord\lib\xstream-1.4.jar

?????文件????????131??2017-02-10?07:33??helloWord\output\data1.xml

?????文件????????452??2017-02-10?07:33??helloWord\output\data2.xml

?????文件????????179??2017-02-10?07:33??helloWord\output\data3.xml

?????文件???????1948??2017-02-10?07:32??helloWord\src\com\test\CsvToxml1.java

?????文件???????1615??2017-02-10?00:31??helloWord\src\com\test\CsvToxml2.java

?????文件???????2464??2017-02-10?07:33??helloWord\src\com\test\CsvToxml3.java

?????文件????????482??2017-02-09?23:27??helloWord\src\com\test\TreeNode.java

?????文件????????793??2017-02-10?00:26??helloWord\src\com\test\TreeUtil.java

?????目錄??????????0??2017-02-10?00:27??helloWord\bin\com\test

?????目錄??????????0??2017-02-10?00:32??helloWord\src\com\test

?????目錄??????????0??2017-02-09?23:54??helloWord\bin\com

?????目錄??????????0??2017-02-09?21:54??helloWord\src\com

?????目錄??????????0??2017-02-09?21:53??helloWord\.settings

?????目錄??????????0??2017-02-09?23:54??helloWord\bin

?????目錄??????????0??2017-02-09?23:54??helloWord\lib

?????目錄??????????0??2017-02-10?00:32??helloWord\output

?????目錄??????????0??2017-02-09?21:54??helloWord\src

?????目錄??????????0??2017-02-10?00:31??helloWord

............此處省略3個文件信息

評論

共有 條評論