首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

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

2012-08-26 
缓冲流怎么加啊,大神帮我看看import java.io.*class A{public static void main (String [] args)throws

缓冲流怎么加啊,大神帮我看看
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 ();    }} 

热点排行