webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Compressed empty bytes need to be Handle

  • 1.  Compressed empty bytes need to be Handle

    Posted Thu December 08, 2016 03:15 AM

    Hello,

    I had written a java code in which it handle compressed files in which if byte content is not empty but now I need even though the byte content is empty the data should be decompressed or unzip.Below is the code which is working for unzipped or uncompressed with out empty.

    Finally i need an empty bytes to be unzipped

    Could any one please help me.

    Input: bytes

    output:stream

    [/code]

    public static final void unzipBytesToStream(IData pipeline)
    throws ServiceException {
    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();
    Object bytesObj = IDataUtil.get( pipelineCursor, “bytes” );
    pipelineCursor.destroy();

    	if (!(bytesObj instanceof byte[])) {
    throw new ServiceException("Bytes must be a byte array!");
    }
    try {
    java.util.zip.GZIPInputStream zipIS = new java.util.zip.GZIPInputStream(new ByteArrayInputStream((byte[]) bytesObj));
    
    // pipeline
    pipelineCursor = pipeline.getCursor();
    IDataUtil.put( pipelineCursor, "stream", zipIS );
    pipelineCursor.destroy();
    }
    catch (IOException e) {
    throw new IllegalArgumentException("Invalid content: " + e.getMessage());
    }
    }
    

    #webMethods
    #Integration-Server-and-ESB


  • 2.  RE: Compressed empty bytes need to be Handle

    Posted Fri December 09, 2016 04:44 AM

    Hi,

    If zip(empty)=empty then unzip(empty)=empty too?

    So if you could add a check for an empty input before calling the unzip service, you could return an empty output.

    Would this work?

    Best Regards,


    #Integration-Server-and-ESB
    #webMethods