create multiple files from zip file using java and pl sql

Hi all

I wrote the java code in oracle database 11 g 2 below.

DROP JAVA SOURCE SCOTT."CreateZip";

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED SCOTT."CreateZip" 
as 
  import java.io.BufferedInputStream;
  import java.io.BufferedOutputStream;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.util.zip.Deflater;
  import java.util.zip.ZipEntry;
  import java.util.zip.ZipInputStream;
  import java.util.zip.ZipOutputStream;
  
  public class CreateZip 
  {  
    
    //public static final int BUFFER_SIZE = 4096;
    
    public static void Zip(String zipFileName, String zipEntries) throws IOException
    {
      
      //String strName = zipEntries;
      String[] srcFiles = new String[] {zipEntries};
      //String[] srcFiles = {zipEntries};
       
      try
      {
          byte[] buffer = new byte[4096];
          FileOutputStream fos = new FileOutputStream(zipFileName);
          ZipOutputStream zos = new ZipOutputStream(fos);        
      
          for (int i = 0; i < srcFiles.length; i++) 
          {
              File entryFile = new File(srcFiles[i]);
              FileInputStream fis = new FileInputStream(entryFile);
              zos.putNextEntry(new ZipEntry(entryFile.getName()));


              int length;
              
              while ((length = fis.read(buffer)) > 0)
              {
               zos.write(buffer, 0, length);
              }
              zos.closeEntry();
              // close the InputStream
              fis.close();
          }
          // close the ZipOutputStream
          zos.close();
      }
      catch (IOException e) 
      {
       e.printStackTrace();
      }
       
    }
    
    public static void UnZip(String zipFilePath, String destDirectory) throws IOException 
    {
     
     try
      {
       byte[] buffer = new byte[4096];   
       //create output directory is not exists
        File folder = new File(destDirectory);
        if(!folder.exists())
        {
            folder.mkdir();
        }
        //get the zip file content
        ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFilePath));
        //get the zipped file list entry
        ZipEntry ze = zis.getNextEntry();
        
        while(ze!=null)
        {
          String fileName = ze.getName();
          File newFile = new File(destDirectory + File.separator + fileName);
          //create all non exists folders
          //else you will hit FileNotFoundException for compressed folder
          new File(newFile.getParent()).mkdirs();
          FileOutputStream fos = new FileOutputStream(newFile);
          int len;
          while ((len = zis.read(buffer)) > 0)
             {
              fos.write(buffer, 0, len);
             }
             
          fos.close();   
          ze = zis.getNextEntry();
          
        }
        zis.closeEntry();
        zis.close();
      }
      catch (IOException e) 
      {
       e.printStackTrace();
      }
      
    }
    
    
  }
/

and the pl/sql wrapper is lower.

CREATE OR REPLACE PACKAGE SCOTT.CreateZip AS
PROCEDURE UnZip(Param1 VARCHAR2, Param2 VARCHAR2) 
AS
  LANGUAGE java 
    NAME 'CreateZip.UnZip(java.lang.String, java.lang.String)';


PROCEDURE Zip(Param1 VARCHAR2, Param2 VARCHAR2) 
AS
  LANGUAGE java 
    NAME 'CreateZip.Zip(java.lang.String, java.lang.String)';
end;
/

but my problem is to unzip code works file while the Zip function does not work.

I passing the path with file name as this to create the table in java in the Zip function

Zip('d:\EXCEL_ORACLE_DIR\Test.zip','d:\EXCEL_ORACLE_DIR\abc.txt,D:\EXCEL_ORACLE_DIR\abc.docx').

creates the zip file with the size of zero byte, where is the problem.

The problem is in line 26 because you split an array of String [] zipEntries...

Try this

String [] srcFiles = zipEntries.split(",");

You exception, but you don't know in plsql procedure...

Try to change your java method...

Tags: Database

Similar Questions

  • Print multiple files using Java script in a form

    Hi, I am new to scripting and wanted to be able to have a button on a PDF file that would send several PDF files to the default printer.  The files have different numbers of pages each.  I don't want to send all the files in the same folder as the PDF with the print button in the printer.  Is there a script that I can put in the form that will do it?

    Thank you

    Rob

    This is only possible when you know the name of the files. Acrobat JavaScript cannot access a folder and search for documents.

  • Loading multiple files using the same interface in ODI

    Hi all

    We load multiple files using the same interface and get the error "java.sql.SQLException: ORA-00942: table or view does not exist" while inserting record in the staging table. It looks like the same temporary table is used when loading multiple files and the error. Grateful if someone offers a solution to avoid this error.
    We use the following KMS:

    (1) LKM SQL file
    (2) IKM Oracle SQL COMMAND append.

    Receive a quick response.

    Thank you
    RP

    Hello

    See this http://odiexperts.com/interface-parallel-execution-a-new-solution

    Thank you
    Fati

  • create the file using flex

    Hello

    I work in flex.

    I want to create the file using flex 4.

    I use this code

    private var file:File;

    private function addfolder (): void

    {

    file = new File ("file:///C:/MyNewFolder");

    file.createDirectory ();

    }

    the error is

    Type was not found or was not a compilation constant: file.

    anyone helpme

    concerning

    Athi

    Hello

    With flex, you need to display the filereference function record. Because of the security sandbox you cannot programmatically save files or create folders, you need to open a box to browse to windows files, so the user can create a folder or save a file.

    private void testme (): void

    {

    var fi: FileReference = new FileReference();

    fi. Save ('Hello');<=== this="" would="" open="" a="" system="" file="" save="">

    }

    David.
  • I want to create new sequence from a clip using script.

    I want to create new sequence from a clip using script.

    You can pop the dialog box new sequence (which requires interaction from the user to confirm the name of sequence), or create a new sequence from a .sqpreset file (and specify the name); There is no API around the feature 'make a sequence corresponding to this project item', available in the project Panel.

  • Chinese characters appear from nowhere, then using find and replace in dreamweaver

    It is a strange, Chinese characters appear from nowhere, then using find and replace (in the folder) in dreamweaver. the replacement text is Chinese characters on the open document, others are ok

    Sounds like the Configuration of your entire file is damaged.

    Rename your folder Dreamweaver MX\Configuration Old_Configuration.

    When you restart Dreamweaver, it will create a new Configuration file for you.

    Good luck!

    Nancy O.

  • Looking for adobe certified companies that can create a web site of muse with java and PHP for me

    Looking for adobe certified companies that can create a web site of muse with java and PHP for me

    Relationship problems he...

    1: nothing like the Adobe Certified companies

    2: sites of Muse do no PHP support.

  • How can I create multiple PDFs from multiple files in Acrobat DC?

    How to convert a large number of files to PDF in Acrobat DC? Currently, I can only find a guide to Acrobat X

    Launch the tool "create a PDF file. Select "multiple files" | «Create multiple PDF files»

  • What is the best way to adjust the brightness in multiple files using elements 13?

    I have about 100 JPEGs that I need to cheer up.  I need to adjust the brightness in "100" on each; is there a quick way?  "Treat multiple files" does not...

    Thank you!

    john_oc wrote:

    I have about 100 JPEGs that I need to cheer up.  I need to adjust the brightness in "100" on each; is there a quick way?  "Treat multiple files" does not...

    Thank you!

    Simple and powerful: use the ACR (Camera raw).

    Depending on the power and the amount of RAM on your computer, you can now open and edit multiple files at the same time in the ACR module.
    Use the menu file/open in camera raw.

    Select a batch of files (say 20 to begin by)

    Select all the files in the camera roll on the left.

    When they are highlighted, you will notice that the ACR module shows its AutoCorrect settings. Generally the brightness of your images will already be improved.

    The changes you apply to the sliders will change all the images highlighted.

    Take advantage of the opportunity to refine all the other sliders made highlights/shadows, clarity, vibrance, sharpening or noise reduction...

    Tip:

    What you do in the ACR module do not alter the original jpeg pixels. Only the parameters are saved, which is called parametric edition. So after this editing session, when you save the changes ('Done' button), you are able to reopen the jpeg (it will open automatically in ACR, even from the Organizer). You will be able to start editing with either:

    1 - the values of the original jpeg (turn all the sliders to zero, auto or custom in the right panel).

    2 - the AutoCorrect default CAB
    3 - your latest changes (settings file)
    4 - the session settings of most recent edition (which is useful to apply to several image consecutively).

    These settings are saved in the jpeg metadata section. No need to create a version set at this stage.

    Important: even if you are happy with the automatic settings default to ACR, apply a little change of your choice so that the settings are saved in the metadata section when you click on 'Done '.

    You have now edited your first batch. If you use the orgnizer, you might want to "update thumbnails', which show the improvement of brightness in thumbnails. You are ready to make the necessary changes to individual files, such as cropping or sharpening in ACR. Instead of clicking "Done", you can click on 'Open' to open the file in the Editor (you can change in 8 or 16-bit). You must go into the editor to apply other changes as layers, local adjustments. you use the editor to register in any other format file or print.

    For the next batch, the mounting parameters are available in the dropdown to the right (previous conversion). Open files, highlight all, select previous conversion, click 'Done '. Wait for the settings to be saved in jpeg files.

    In a situation where you have 100 files JPEG, the workflow that the above is by far the fastest and most flexible you can use. Imagine you have a white balance bad setting of your camera, you can imagine the time you need by editing individual files in the editor?

  • Dynamically create a file using the variable

    HI, I am facing a problem in creating file on the time of execution using the variable.
    I have a variable file name. In the tab refresh, I wrote a query SELECT TO_CHAR (SYSDATE, 'YYYY, MM, DD') | 'TEST' FOR DOUBLE. I tested the variable and its value is correct.

    I've created an interface allowing to extract the data in the table and store it in the file. I assigned the variable file name in the file.

    Now when I run the interface... the file is created, but the header is created in different file and its name is ambiguous, g (19) and the data are placed in the other file with the name that matches the value of the variable filename...

    It is two ODI creates two files a single header and other data...

    When I run my interface in a package of the file created perfectly... but one i want to use package I want to create a file via the interface only running

    What is the name of the second file? (the file that does not have the name of the variable)

  • PES 10 - problem prevents the watermark color setting when processing multiple files using

    I use the batch processing under file > processing of multiple files.  I put the watermark with my text you want, post, police, font size, opacity and color white.  However, every time I come back to deal with another batch of color goes back to the default blue color instead of white that I initially put.

    Does anyone else have this problem?  Are there patches?

    I use Photoshop Elements 10 on a Mac under Lion.

    Thank you.

    At least on windows the color always seems to default to the color set as the foreground color in the Toolbox.

    MTSTUNER

  • FF Sync synchronize really or just copy? If three computers are duplicates are deleted or created multiple files of bookmarks. mybookmarks or mybookmarks-2

    I have a laptop, a desktop XP computer that I'm retired, and a new desktop Windows 7 w / no brand-pages other than the defaults in FF 8.0.

    I really want to synchronize the portable and bookmarks XP desktop then move or synchronize the bookmarks to my new office.

    Sync creates a single bookmark that is actually synchronized between computers or copy one to the next creating several files of bookmarks?

    FF Sync synchronizes your bookmarks between machines. It does not copy only them. For more information: https://support.mozilla.com/en-US/que.../new?product=sync.

  • Get the error when you try to write to a file using java script in my Metro app

    I'm discovering a problem in my App Metro and thought that I will create a file to copy all log messages in ther... I tried the following

    var LogFile = "LogFile.txt";

    () Windows.Storage.DownloadsFolder.createFileAsync("LogFile.txt").done

    {function (file)

    LogFile = file;

    });

    Windows.Storage.FileIO.appendLinesAsync (log file, "Test") .done ();<-- line="">

    but then, I get the following error:

    Unhandled exception, line 26, column 5 in ms-appx://windowsmultimediaperformanceapplication/js/default.js

    0x800a000d - JavaScript runtime error: Type mismatch

    It creates the file correctly, but it fails to write to it. Any help will be appreciated. I looked at the code example provided and talked about when writing this.

    Hey Kajal,

    The question you posted would be better suited in the MSDN Forums. I would recommend posting your query in the MSDN Forums.

    http://social.msdn.Microsoft.com/forums/en-us/winappswithhtml5/threads

  • Creating text file use new file, by returning the result by completely removing the lines of code to extend script?

    Hi guys

    Creating new files .txt in extendscript thru new file returns results by removing all the code in extend script.

    Example of

    -------------------

    var fPerCode = 'hack ';

    var myFileP = new File($.fileName);

    var myFilePtS = myFileP.parent.fsName.toString ();

    myFileP.open ('w');

    myFileP.write (fPerCode);

    myFileP.copy(myFilePtS+"\\"+"Mytools_icons"+"\\"+"name.txt");

    myFileP.close ();

    Alert ("path to the fullper.bat file" + "\n"+myFilePtS+"\\"+"Mytools_icons"+"\\"+"name.txt");

    If you run the above code, you see the result by disabling all of the code above.

    can someone help with this problem?

    You have a problem that you are writing your own script file and then doing a copy...

    You also toString() of unnecesery and deformities (+).

    Here is a fix your code:

    var fPerCode = 'hack ';

    var myFileP = new File($.fileName);

    var myFilePtS = myFileP.parent.fsName;

    var myNewFile = new File (myFilePtS + "\\Mytools_icons\\name.txt");

    myNewFile.open ('w');

    myNewFile.write (fPerCode);

    myNewFile.close ();

    Alert ("path to fullper.bat file\n" + myNewFile.fsName);

  • ability to create multiple PDFs from links?

    Acrobat Pro X, is there a way to apply the option 'create pdf file of the link' several links on the same website at the same time? Thank you

    About the closest you can get is to use tools > Document Processing > Web Capture > add all links on the page control, which will go through the links and add to your existing PDF that has been captured from a web site.

Maybe you are looking for

  • No appearance in the 9.0.2 safari preferences settings

    updated at EL Capitan 10.11.2 and Safari 9.0.2 Safari 9.0.2 has more appearances by setting the option in Safari preferences

  • Button-table with colors?

    Hey everybody, I made a matrix table buttons (please open my attached picture to understand what I wanted). I want to do two things: 1 make the clickable buttons, and to make an event every time that one of them was clicked by the user. 2. to control

  • Cannot find download driver for InkJet P2015 for Mac

    Hello I just got a new iMac running OS 10.10.1 and hope that I can still use my HP printer. I had a great 2015 LaserJet for years and there is absolutely nothing wrong with that, but I can't seem to find the driver online download. I was on the site

  • Graphic card vs compatibility PCI - E motherboard

    Hello I have a new card in my PC, but I'm afraid a bit with the PCI-E card and the motherboard.My PC can be found here: http://support.hp.com/us-en/document/c01982717While the map I want to buy can be found here: http://www.newegg.com/Product/Product

  • Background App PlayBook

    Hey guys,. When I run my application flash from adobe on the playbook Simulator, I see the bottom of the home screen, like the bottom of my app is meant to be like that? How can I change this?