filipe6 0 Denunciar post Postado Novembro 27, 2006 Olha que eu fiz mais não funciona :import java.util.zip.ZipOutputStream;import java.util.zip.ZipEntry;import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStreamReader;public class CreateZipFile {int TAM_BUFFER = 1024 ; public void zipa(String saida1, String nomeZip) { int i, cont; File f = null; FileInputStream fileinput = null; FileOutputStream fileoutput = null; BufferedInputStream buffer = null; ZipOutputStream zipar = null; ZipEntry entry = null; byte[] dados = new byte[TAM_BUFFER]; fileoutput = new FileOutputStream(saida1); zipar = new ZipOutputStream(new BufferedOutputStream(fileoutput)); BufferedReader leia = new BufferedReader(new InputStreamReader(System.in)); f = new File(nomeZip); if (f.isFile() && !(f.getName()).equals(fileoutput)){ System.out.println("Compactando: " + f); fileinput = new FileInputStream(f); buffer = new BufferedInputStream(fileinput,TAM_BUFFER); entry = new ZipEntry(nomeZip); zipar.putNextEntry(entry); while((cont = buffer.read(dados, 0, TAM_BUFFER)) != -1) { zipar.write(dados, 0, cont); }//while buffer.close(); zipar.close(); } } public static void main(String[] args) throws IOException { zipa("c:\\teste\\GeraDadosReiterados.ec","c:\\teste\\GeraDadosReiterados.zip"); }} Compartilhar este post Link para o post Compartilhar em outros sites
Ratu 0 Denunciar post Postado Novembro 28, 2006 da algum erro? Compartilhar este post Link para o post Compartilhar em outros sites