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文件里

  • 相关阅读:
    Linux 命令
    Linux 命令
    Linux 命令
    Linux 命令
    121.Best Time to Buy and Sell Stock---dp
    136.Single Number---异或、位运算
    141.Linked List Cycle---双指针
    Restful接口设计
    socket网络编程
    107.Binary Tree Level Order Traversal II
  • 原文地址:https://www.cnblogs.com/092e/p/14148218.html
Copyright © 2011-2022 走看看