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();
    }

posted @ 2014-06-16 09:48  清风yi竹  阅读(120)  评论(0编辑  收藏  举报