java 输出流

//输出流
    @Test
    public void testOutStream() throws Exception{
        OutputStream  out =new FileOutputStream("abc.txt");
        String content="hello word/nwww.baidu.com ";
        byte[]contentBytes=content.getBytes();
        out.write(contentBytes);
        out.close();
    }
    //文件的拷贝
    @Test
    public void copyFile() throws Exception {
        InputStream in=new FileInputStream("abc.txt");
         OutputStream  out =new FileOutputStream("abc2.txt");
        byte[]buffer=new byte[10];
        int len=0;
        while((len=in.read(buffer))!=-1){
            out.write(buffer, 0, len);;
        }
        in.close();
        out.close();
    }

原文地址:https://www.cnblogs.com/liuquande/p/3790377.html