Using the input and output streams knowledge, copy files from the source file path to the destination path

com.itcast.demo02.InputStream Package ; 

Import a java.io.FileInputStream ;
Import java.io.FileOutputStream ;
Import java.io.IOException ;

/ **
* @author newcityman
* @date 2019/7/28 - 9:38
* topics requirements:
* using knowledge input and output streams, copying files from the source file path to the destination path
* /
public class Demo03InputStream {
public static void main (String [] args) throws IOException {
Long L = the System. with currentTimeMillis () ;
FIS = FileInputStream new new FileInputStream ( "D: \\ festival task .docx") ;
FileOutputStream fos =new FileOutputStream("F:\\1.docx");
byte[] bytes = new byte[2048];
int len = 0;
while((len=fis.read(bytes))!=-1){
fos.write(bytes,0,len);
}
fis.close();
fos.close();
long l1 = System.currentTimeMillis();
System.out.println("总耗时:"+(l1-l)+"毫秒");

}
}

Guess you like

Origin www.cnblogs.com/newcityboy/p/11257882.html