写入中文乱码解决方案

private void saveAsFileWriter(String content,String file) {

        try
        {
            File f = new File(file);
            if (!f.exists())
            {
                f.createNewFile();
            }
            **OutputStreamWriter write = new OutputStreamWriter(new FileOutputStream(f),"UTF-8");**
            BufferedWriter writer=new BufferedWriter(write);
            writer.write(content);
            writer.close();
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }

你可能感兴趣的:(写入中文乱码解决方案)