BufferdInputStream和BufferdOutputStream

版权声明:正在学习中,有错误欢迎指出。感谢比❤❤~ https://blog.csdn.net/gx17864373822/article/details/79972299
import java.util.Arrays;
import java.util.Scanner;
import java.io.*;
public class Main2
{ 
 public static void main(String[] args) throws IOException
   {
   InputStream is=new FileInputStream("c:\\abc.txt");
   OutputStream os=new FileOutputStream("d:\\abc.txt");

   BufferedInputStream bis=new BufferedInputStream(is);   //1
   BufferedOutputStream bos=new BufferedOutputStream(os); //2

   long l1=System.currentTimeMillis();
   byte[] bytes=new byte[10];
   int len;
   while((len=bis.read(bytes))!=-1)   //3
   {
    bos.write(bytes,0,len);           //4
    System.out.println(new String(bytes,0,len));
   }

   bis.close();   //5
   bos.close();   //6
   is.close();
   os.close();

   long l2=System.currentTimeMillis();
   System.out.println(l2-l1);
   }
 }
阅读更多

没有更多推荐了,返回首页