IO流初解---------OutputStream

import java.io.*;
public class newcollection {
    public static void main(String args[]) 
    {
        
            OutputStream out=System.out;//实例化OutputStream类
            try
            {
                byte[]bte="本实例使用OutputStream输出流,在控制台输出字符串\n".getBytes();//向流中写入数据
                out.write(bte);//向流中写入数据
                bte="输出内容\n".getBytes();
                out.write(bte);
                bte="你是煞笔".getBytes();
                out.write(bte);
                out.write(bte,2,2);//将byte[]数组从0开始2个长度的数据写入流
                out.close();
            } catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_41191715/article/details/82940108