当前位置: 代码迷 >> J2SE >> 缓冲流如何加啊大神帮小弟我看看
  详细解决方案

缓冲流如何加啊大神帮小弟我看看

热度:88   发布时间:2016-04-24 00:24:53.0
缓冲流怎么加啊,大神帮我看看
import java.io.*;
class A
{
public static void main (String [] args)throws Exception
{
BufferedInputStream mm = new BufferedInputStream (aa);
BufferedOutputStream nn = new BufferedOutputStream( bb);
FileInputStream aa = new FileInputStream ("D:\\1.txt");
FileOutputStream bb = new FileOutputStream ("D:\\2.txt");
byte [] cc = new byte [1024];
int len = aa.read (cc);
while (-1!=len)
{
bb.write (cc);
len = aa.read (cc);
}
bb.flush();
bb.close();
aa.close ();
}
}
这里缓冲流我知道写错了求大神指点

------解决方案--------------------
Java code
import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;public class Test {    public static void main(String[] args) throws IOException {                FileInputStream aa = new FileInputStream ("D:\\1.txt");        FileOutputStream bb = new FileOutputStream ("D:\\2.txt");                BufferedInputStream mm = new BufferedInputStream (aa);        BufferedOutputStream nn = new BufferedOutputStream( bb);                byte [] cc = new byte [1024];        int len = mm.read (cc);        if (-1 != len)        {            nn.write (cc);        }        nn.close();        mm.close ();    }}
  相关解决方案