java 输出流

时间:2014-06-18 21:16:47   收藏:0   阅读:280

//输出流
    @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();
    }

java 输出流,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!