Java Source Oracle para comprimir Archivos

DROP JAVA SOURCE "ComprimirArchivo";

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "comprimirArchivo" as import java.util.zip.*;

import java.io.*;

public class ComprimirArchivo

{

public static String ComprimeArchivo(String infilename, String

outfilename)

{

try

{

FileOutputStream fout = new FileOutputStream(outfilename);

ZipOutputStream zout = new ZipOutputStream(fout);

ZipEntry ze = new ZipEntry((new File(infilename)).getName());

try

{

FileInputStream fin = new FileInputStream(infilename);

zout.putNextEntry(ze);

copy(fin, zout);

zout.closeEntry();

fin.close();

}

catch (IOException ie)

{

System.out.println("IO Exception occurred: " + ie);

return ie.toString();

}

zout.close();

}

catch(Exception e)

{

System.out.println("Exception occurred: " + e);

return e.toString();

}

return "OK";

}

public static void copy(InputStream in, OutputStream out)

throws IOException

{

byte[] buffer = new byte[4096];

while (true) {

int bytesRead = in.read(buffer);

if (bytesRead == -1) break;

out.write(buffer, 0, bytesRead);

}

}

}

/
CREATE OR REPLACE PACKAGE ComprimirArchivo

IS

FUNCTION ComprimeArchivo (p_in_file IN VARCHAR2, p_out_file IN

VARCHAR2)

return varchar AS

LANGUAGE JAVA

NAME 'ComprimirArchivo.ComprimeArchivo(java.lang.String,java.lang.String) return String';

END;

/

JulexFR