利用FileInputStream和FileOutputStreamj进行复制粘贴

/*
    文件复制粘贴
*/

import java.io.*;
public class FileInput_OutputStreamCopy
{
    public static void main(String[] args) throws Exception
    {
        
        //创建输入流
        FileInputStream fis = new FileInputStream("FileInput_OutputStreamCopy.java");

        //创建输出流
        FileOutputStream fos = new FileOutputStream("D:\\FileInput_OutputStreamCopy.java");

        int temp = 0;
        byte[] bytes = new byte[1024];

        while((temp = fis.read(bytes)) != -1){
            //将byte数组中内容直接写入
            fos.write(bytes,0,temp);
        }

        fos.flush();

        fis.close();        
        fos.close();
    }
}

 

相关文章:

  • 2021-06-23
  • 2021-08-08
  • 2022-01-16
  • 2021-12-04
  • 2021-05-27
  • 2021-06-25
  • 2021-08-13
  • 2022-03-08
猜你喜欢
  • 2021-10-10
  • 2021-10-23
  • 2022-01-11
  • 2021-10-29
  • 2021-12-12
  • 2022-01-27
  • 2021-08-24
相关资源
相似解决方案