[Java 12 IO] OutputStream 字节输出流,继承自它的类,都是 程序中输出 数据

OutputStream 字节输出流,继承自它的类,都是 程序中输出 数据

OutputStreamDemo01

package com.qunar.basicJava.javase.io;

import java.io.*;

/**
 * Author: libin.chen@qunar.com  Date: 14-6-5 15:58
 */
public class OutputStreamDemo01 {
    public static void main(String[] args) throws IOException {
        // 第 1 步 : 使用 File 类找到一个文件
        File file = new File("/home/hp/tmp/test.txt");
        // 第 2 步 : 通过子类实例化父类对象
        OutputStream outputStream = new FileOutputStream(file);
        // 第 3 步 : 进行写操作
        String str = "Hello World!!!!!";
        byte b[] = str.getBytes();
        outputStream.write(b);
        // 第 4 步 : 关闭输出流
        //Thread.sleep(3000);
        outputStream.flush();
        outputStream.close();

    }
}

转载于:https://www.cnblogs.com/robbychan/p/3786495.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值