Here you can find the source of copyFile(String s, String s1)
public static final void copyFile(String s, String s1)
//package com.java2s; /*/*www. j a va 2s . c om*/ * Copyright 2014-2024 the https://github.com/xiaoxing598/itganhuo. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * This project consists of JAVA private school online learning community group Friends co-creator [QQ group 329232140]. * ????JAVA???????????????????[QQ?329232140]; * See the list of IT dry technology sharing network [http://www.itganhuo.cn/teams]. * ???????????IT???????[http://www.itganhuo.cn/teams]; * The author does not guarantee the quality of the project and its stability, reliability, and security does not bear any responsibility. * ?????????????????????????????????????????. */ import java.io.FileInputStream; import java.io.FileOutputStream; public class Main { public static final void copyFile(String s, String s1) { FileInputStream fileinputstream = null; FileOutputStream fileoutputstream = null; try { fileinputstream = new FileInputStream(s); fileoutputstream = new FileOutputStream(s1); int j; byte abyte0[] = new byte[1024]; do { int i; j = fileinputstream.read(abyte0); i = j; if (j == -1) break; fileoutputstream.write(abyte0, 0, i); } while (true); } catch (Exception exception) { exception.printStackTrace(); } finally { try { fileinputstream.close(); fileoutputstream.close(); } catch (Exception exception) { exception.printStackTrace(); } } } }