// Decompiled by DJ v3.12.12.96 Copyright 2011 Atanas Neshkov  Date: 08/10/2012 8:47:47
// Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   GuardarVideo.java

package project;

import java.io.*;
import java.net.HttpURLConnection;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class GuardarVideo
{

    public GuardarVideo(File arrayDeFicheros[])
    {
        BUFFER = 10240;
        dest = null;
        try
        {
            for(int i = 0; i < arrayDeFicheros.length; i++)
                if(arrayDeFicheros[i].getName().endsWith(".zip"))
                {
                    zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(arrayDeFicheros[i])));
                    ZipEntry entry = null;
                    do
                    {
                        if((entry = zis.getNextEntry()) == null)
                            break;
                        if(entry.getName().endsWith(".mov"))
                        {
                            byte data[] = new byte[BUFFER];
                            fos = new FileOutputStream(System.getProperties().getProperty("user.dir") + "/java/NuevosVideos/" + entry.getName().substring(entry.getName().lastIndexOf("/")));
                            dest = new BufferedOutputStream(fos, BUFFER);
                            int count;
                            while((count = zis.read(data, 0, BUFFER)) != -1) 
                                dest.write(data, 0, count);
                            dest.flush();
                            dest.close();
                        }
                    } while(true);
                    zis.close();
                }

        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }

    int BUFFER;
    InputStream input;
    InputStream input2;
    FileOutputStream fos;
    BufferedOutputStream dest;
    HttpURLConnection connection;
    ZipInputStream zis;
}