no_russion
no_russion
2019-07-17 14:00

java输入输出问题,为什么想写入的是12345,但是输出却是0

  • java
  • java-ee
  • eclipse
package 流;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.Buffer;

public class 写入
{

    public static void main(String[] args)
    {
        // TODO Auto-generated method stub
        try
        {
            DataOutputStream out=new DataOutputStream
                    (
                            new BufferedOutputStream
                            (
                                    new FileOutputStream("b.dat")
                            )
                    );
            out.writeInt(12345);
            out.close();
            DataInputStream in=new DataInputStream
                    (
                            new BufferedInputStream
                            (
                                    new FileInputStream("b.dat")
                            )
                    );
            System.out.println(in.read());
        } catch (FileNotFoundException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐

换一换