赞
踩
首先,引入dependency
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
实现文件复制:
import org.apache.commons.io.IOUtils; import java.io.*; public class Main { public static void main(String[] args) throws IOException { FileInputStream fileInputStream=null; FileOutputStream fileOutputStream=null; fileInputStream = new FileInputStream("D://uploadanddownload-0.0.1-SNAPSHOT.jar"); File file = new File("D://a/b"); file.mkdirs(); fileOutputStream=new FileOutputStream("D://a/b/uploadanddownload-0.0.1-SNAPSHOT.jar"); IOUtils.copy(fileInputStream,fileOutputStream); IOUtils.closeQuietly(fileInputStream); IOUtils.closeQuietly(fileOutputStream); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。