java io文件的复制(源码)

it2025-02-12  10

话不多说上源码

//复制功能 public void copy(String srcpath, String dstpath) throws IOException { File files = new File(srcpath); File filed = new File(dstpath); FileInputStream fis = new FileInputStream(srcpath); FileOutputStream fos = new FileOutputStream(dstpath); byte[] b = new byte[1024]; int len = 0; while ((len = (fis.read(b))) != -1) { fos.write(b, 0, len); } fis.close(); fos.close(); }
最新回复(0)