qq_35464738
jessica_kqq
2017-11-19 11:33

FileoutputStream输出问题

  • java

import java.io.*;

public class FileOutputStreamTest {

public static void main(String[] args) {

        FileInputStream in = null;
        FileOutputStream out = null;
        int b=0;

        byte[] t = new byte[6];

        try {
            in = new FileInputStream("D:\\asd.txt");

            out = new FileOutputStream("D:\\dsa.txt");


            while((b=in.read(t))!=-1) {

                out.write(t,0,6);

            }
            in.close();
            out.flush();
            out.close();



        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.out.print("找不到文件");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.out.print("读取错误");
        }
        System.out.print("文件成功复制");
}

}

asd.txt中的内容为:a A 567
输出的内容为:a A 567 A 56
不懂?求解释一下。

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

1条回答

为你推荐

换一换