zoukankan      html  css  js  c++  java
  • 输出流

    11.13

    今天练习了输出流的代码:

    代码部分:

    package lianxi;
    import java.io.*;
    public class bo
    {
    public static void main(String[] args) throws IOException {
    FileInputStream fis = null;
    FileOutputStream fos = null;
    try {
    //创建字节输入流
    fis = new FileInputStream("D://b.txt");
    //创建字节输入流
    fos = new FileOutputStream("D://c.txt");
    byte[] bbuf = new byte[32];
    int hasRead = 0;
    //循环从输入流中取出数据
    while ((hasRead = fis.read(bbuf)) > 0) {
    //每读取一次,即写入文件输出流,读了多少,就写多少。
    fos.write(bbuf, 0, hasRead);
    }
    } catch (IOException ioe) {
    ioe.printStackTrace();
    } finally {
    //使用finally块来关闭文件输入流
    if (fis != null) {
    fis.close();
    }
    //使用finally块来关闭文件输出流
    if (fos != null) {
    fos.close();
    }
    }
    }
    }

     运行结果:

     

     运行结果分析:

    成功的吧b文件里的内容输入道了c文件里

  • 相关阅读:
    博客园转文章的方法
    http协议相关面试题
    接口测试基础01
    文件上传下载
    括号-回溯
    幂集-回溯
    分割数组为连续子序列- -贪心法
    不使用临时变量交换数字
    计数质数
    拼接最大值
  • 原文地址:https://www.cnblogs.com/092e/p/14148218.html
Copyright © 2011-2022 走看看