导出csv文件乱码

      private static void writeBcp( ) throws IOException
      {
            //Create bcp file if not exist
                        File bcpFile = new File("test.csv");
                        //bcpFile.delete();
                        byte[] bom ={(byte) 0xEF,(byte) 0xBB,(byte) 0xBF};
                        //boolean newFile = false;
                        FileOutputStream bcpFileWriter = new FileOutputStream(bcpFile);
                        bcpFileWriter.write(bom);
                  //bcpFile.delete();
                        String title = "\"MD5\",\"扫描文件名\",\"扫描时间\"," +
                        "\"是否病毒\",\"安全等级\",\"病毒英文名称\"," +
                        "\"病毒变种\",\"病毒类型\",\"病毒影响\"," +
                        "\"感染系统\",\"传播方式\",\"备注\"";
                       
                       
                        bcpFileWriter.write((new String(title.getBytes(), "utf-8")).getBytes());
                        bcpFileWriter.write("\n".getBytes());
                       
                        String appStr = "\""+123+"\","
                        +"\""+123+"\","
                        +123+","
                        +123+","
                        +123+","
                        +"\""+123+"\","
                        +"\"\","
                        +123+","
                        +"\""+123+"\","
                        +"\""+123+"\","
                        +"\""+123+"\","
                        +"\""+123+"\"\n";
                       

                        bcpFileWriter.write(appStr.getBytes());
                        bcpFileWriter.close();
                       
      }

 

你可能感兴趣的:(Java)