【FileInputStream類:讀取陣列】
阿新 • • 發佈:2018-11-11
package test; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; /** * @author shusheng * @description * @Email [email protected] * @date 2018/11/9 16:16 */ public class FileInputStreamDemo2 { public static void main(String[] args) throws IOException {//封裝資料來源 FileInputStream fis = new FileInputStream("d:\\aaa.zip"); //封裝目的地 FileOutputStream fos = new FileOutputStream("e:\\bbb.zip"); //讀取資料 //定義一個位元組資料 //陣列的長度一般是1024或者1024的整數倍 byte[] by = new byte[1024]; int len = 0; while ((len = fis.read(by)) != -1) { fos.write(by); } } }