日期:2014-05-20  浏览次数:20805 次

java里面输入输出流的一个乱码问题
我运行这个代码后,写入的文件里面全部是乱码,高手门,如何解决啊,谢谢
import   java.io.*;
public   class   Main   {
        public   static   void   main(String[]   args)   {
                int   ch   ;
                InputStreamReader   iin   =   new   InputStreamReader(System.in);
                BufferedReader   bin     =   new   BufferedReader(iin);
                File   file1   =   new   File( "D:\\test\\111.txt ");
                try
                {
                        FileOutputStream   fout   =   new   FileOutputStream(file1);
                        DataOutputStream   dout   =   new   DataOutputStream(fout);
                        System.out.println( "输入整数 ");
                        int   i   =   Integer.parseInt(bin.readLine());
                        System.out.println( "输入浮点数 ");
                        float   f   =   Float.parseFloat(bin.readLine());
                        System.out.println( "输入布尔量 ");
                        boolean   b   =   new   Boolean(bin.readLine()).booleanValue();
                        dout.writeInt(i);
                        dout.writeFloat(f);
                        dout.writeBoolean(b);
                        dout.close();

                }
                catch   (FileNotFoundException   e)
                {
                        System.out.println(e);
                }
                catch   (IOException   e)
                {
                        System.out.println(e);
                }

        }
}


------解决方案--------------------
乱码是正常的,不影响你写入的内容,这一点如果你把你写入的内容重新读回来的话,就知道了
------解决方案--------------------
public static void main(String[] args) {
InputStreamReader iin = new InputStreamReader(System.in);
BufferedReader bin = new BufferedReader(iin);