CSV file writing to solve Chinese Character garbled

Source: Internet
Author: User
/*** @ Param userinfomap user registration information * @ throws ioexception filenotfoundexception * @ return write user information to the CSV file */public static void writecsv (Map <string, string> userinfomap) {try {// file path for storing dealer ID and dealer information string csvpath = fileutil. getworkingpath (). resolve (configutil. getconfig (). get ("idmappings ")). tostring (); // append the original content. If true is changed to false or the default value is not, the original content will be deleted, and fileoutputstream = new fileoutputstream (csvpath, true) will be added ); // UTF-8 write to prevent garbled outputstreamwriter = new outputstreamwriter (fileoutputstream, "UTF-8"); // catch-up mode bufferedwriter BW = new bufferedwriter (outputstreamwriter); // Add a row of Data BW. newline (); BW. write (userinfomap. get ("openid") + "," + userinfomap. get ("deptid") + "," + userinfomap. get ("deptname") + "," + userinfomap. get ("rolename"); BW. close ();} catch (filenotfoundexception e) {// catch the exception e when the file object is generated. printstacktrace ();} catch (ioexception e) {// catch the exception E. printstacktrace ();}}


This article from "Yu Hong produced" blog, please be sure to keep this source http://5fresh.blog.51cto.com/5472694/1433839

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.