"Go" Java Operation CSV file import and Export

Source: Internet
Author: User

Special Note: I blog part of the reference network other blogs, but I have personally written and verified through. If you find that the blog has errors, please prompt to avoid misleading other people, thank you! Welcome reprint, but remember to indicate the source of the article: http://www.cnblogs.com/mao2080/
1  Public classCsvutils {2     3     /**4      * 5 * Description: Export6      * @author[email protected]7 * @created August 26, 2017 pm 2:39:138      * @since 9      * @paramFile csv (path + file name), CSV file does not exist automatically createdTen      * @paramdataList data (data1,data2,data3 ... ) One      * @return A      */ -      Public Static BooleanExportcsv (file file, list<string>dataList) { -FileOutputStream out=NULL; theOutputStreamWriter OSW =NULL; -BufferedWriter bfw=NULL; -         Try { -out =Newfileoutputstream (file); +OSW =NewOutputStreamWriter (out, "GBK"); -BFW =NewBufferedWriter (OSW); +             if(DataList! =NULL&&!Datalist.isempty ()) { A                  for(String data:datalist) { atBfw.append (data). Append ("\ r")); -                 } -             } -             return true; -}Catch(Exception e) { -             return false; in}finally{ - ioutil.closequietly (BFW, OSW, out); to         } +     } -      the     /** *      *  $ * Description: ImportPanax Notoginseng      * @author[email protected] - * @created August 26, 2017 pm 2:42:08 the      * @since  +      * @paramFile csv (path + file name) A      * @return the      */ +      Public StaticList<string>importcsv (file file) { -List<string> dataList =NewArraylist<string>(); $BufferedReader br =NULL; $         Try {  -BR =NewBufferedReader (Newfilereader (file)); -String line = ""; the              while(line = Br.readline ())! =NULL) {  - Datalist.add (line);Wuyi             } the}Catch(Exception e) { -              Wu}finally{ - ioutil.closequietly (BR); About         } $         returndataList; -     } -}

Reference website

Http://www.cnblogs.com/linjiqin/p/3535067.html

"Go" Java Operation CSV file import and Export

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.