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