ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Unzip using JCN

Post new topic  Reply to topic
 Unzip using JCN « View previous topic :: View next topic » 
Author Message
richdad
PostPosted: Mon Jan 09, 2023 10:31 am    Post subject: Unzip using JCN Reply with quote

Newbie

Joined: 09 Jan 2023
Posts: 2

Hi ,
i have a requirement that the server will send zip files to my queue , from there i need to unzip the contents using jcn and proceed.
I am new to JCN node. can someone help me with sample JCN code.

Thanks.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Mon Jan 09, 2023 10:39 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9394
Location: US: west coast, almost. Otherwise, enroute.

Moved to Broker forum.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
richdad
PostPosted: Mon Jan 09, 2023 10:45 am    Post subject: Reply with quote

Newbie

Joined: 09 Jan 2023
Posts: 2

thanks
Back to top
View user's profile Send private message
axeleli12
PostPosted: Sun Mar 05, 2023 3:09 am    Post subject: Reply with quote

Newbie

Joined: 10 Dec 2022
Posts: 2

Sure, I can help you with a sample JCN code to unzip a file. Here's an example:

Code:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import com.jcn.client.JCN;

public class UnzipFile {

    public static void main(String[] args) throws IOException {

        JCN jcn = new JCN();

        // Connect to the queue
        jcn.connect("your-queue-name", "your-queue-password");

        // Get the message from the queue
        String message = jcn.getMessage();

        // Get the zip file as a byte array
        byte[] zipFileBytes = message.getBytes();

        // Create a new ZipInputStream
        ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(zipFileBytes));

        // Loop through all the entries in the zip file
        ZipEntry zipEntry = zis.getNextEntry();
        while (zipEntry != null) {

            // Get the file name
            String fileName = zipEntry.getName();

            // Create a new file with the same name
            File newFile = new File(fileName);

            // Create the file's parent directories if they don't exist
            if (!newFile.getParentFile().exists()) {
                newFile.getParentFile().mkdirs();
            }

            // Create a new FileOutputStream
            FileOutputStream fos = new FileOutputStream(newFile);

            // Read from the ZipInputStream and write to the FileOutputStream
            byte[] buffer = new byte[1024];
            int len;
            while ((len = zis.read(buffer)) > 0) {
                fos.write(buffer, 0, len);
            }

            // Close the FileOutputStream
            fos.close();

            // Get the next entry in the zip file
            zipEntry = zis.getNextEntry();
        }

        // Close the ZipInputStream
        zis.close();

        // Disconnect from the queue
        jcn.disconnect();
    }
}

This code uses the JCN client library to connect to a queue, get a message, and then unzip the contents of the message. You'll need to replace "your-queue-name" and "your-queue-password" with the actual name and password of your queue.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Unzip using JCN
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.