Java copy file

zhaozj2021-02-08  420

Import java.io. *; public class jcopy {public static void main (string args []) {Try {j opy j = new jcopy (); j.copyfile (new file (args [0]), New file (args [ 1]));} catch (Exception e) {e.printStackTrace ();}} public void CopyFile (File in, File out) throws Exception {FileInputStream fis = new FileInputStream (in); FileOutputStream fos = new FileOutputStream (out) Byte [] buf = new byte [1024]; INT i = 0; while ((i = fis.read (buf))! = - 1) {Fos.Write (buf, 0, i);} fis.close (); Fos.close ();}}

转载请注明原文地址:https://www.9cbs.com/read-896.html

New Post(0)