zoukankan      html  css  js  c++  java
  • 乱码的产生

    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.OutputStream;

    public class CharSetDemo02 {
        public static void main(String[] args) throws Exception {
            File file = new File("f:" + File.separator + "loser.txt");
            File file2 = new File("f:" + File.separator + "winner.txt");
            OutputStream out = new FileOutputStream(file);
            OutputStream out2 = new FileOutputStream(file2);
            byte b[] = "中国、こんいちは!".getBytes("ISO8859-1");
            byte b2[] = "日本、コンバは!!!".getBytes("MS932");
            out.write(b);
            out2.write(b2);
            out2.close();
            out.close();
        }
    }

    乱码产生的原因就有一个,即输出内容的编码(例如:程序指定)与接收内容的编码(如本机环境默认)不一致。

  • 相关阅读:
    codeforce1028A Find Square
    2018ccpc网络赛 Buy and Resell
    差分约束
    Lost Cows
    动态查询区间第k大
    疫情控制
    天天爱跑步
    次小生成树
    树上差分闇の連锁
    Stars in Your Window
  • 原文地址:https://www.cnblogs.com/vonk/p/3927374.html
Copyright © 2011-2022 走看看