1. 程式人生 > 其它 >檔案,圖片FIle

檔案,圖片FIle

        String path = "E:\\ceshi\\gongshi.png";
        File file=new File(path);
        InputStream fis = new FileInputStream(file);
        OutputStream fos = new FileOutputStream(new File("E:\\ceshi\\gongshi2.png"));
        int a = 0;
        byte[] temp = new byte[100];
        while((a = fis.read(temp))>0){
            int b = 0;
            b+=a;
            fos.write(temp,0,b);
        }
        fos.flush();
        fis.close();
        fos.close();