Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7398207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:50:32+00:00 2026-05-29T03:50:32+00:00

Getting data onto inputStream object from web url inputStream = AWSFileUtil.getInputStream( AWSConnectionUtil.getS3Object(null), cdn.generalsentiment.com, filePath);

  • 0

Getting data onto inputStream object from web url

inputStream = AWSFileUtil.getInputStream(
                    AWSConnectionUtil.getS3Object(null),
                    "cdn.generalsentiment.com", filePath);

If they are mutliple files then i want to zip them and sent the filetype as “zip” to struts.xml which does the download.

actually am converting the inputstream into byteArrayInputStream

ByteArrayInputStream byteArrayInputStream = new    
ByteArrayInputStream(inputStream.toString().getBytes());
            while (byteArrayInputStream.read(inputStream.toString().getBytes()) > 0) {
                zipOutputStream.write(inputStream.toString().getBytes());
            }

and then

 zipOutputStream.close();
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        fileInputStream = new FileInputStream(file);
        while (fileInputStream.read(buffer) > 0) {
            byteArrayOutputStream.write(buffer);
        }
        byteArrayOutputStream.close();
        inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
        reportName = "GS_MediaValue_Reports.zip";
        fileType = "zip";
    } 

    return fileType;

But the downloaded zip when extracted gives corrupt files.
Please suggest me a solution for this issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:50:33+00:00Added an answer on May 29, 2026 at 3:50 am

    The short answer is that it’s not how ZipOutputStream works. Since it was designed to store multiple files, along with their file names, directory structures and so on, you need to tell the stream about that explicitly.

    Furthermore, converting a stream to a string is a bad idea in general, plus it’s slow, especially when you’re doing it in a loop.

    So your solution will be something like:

    ZipEntry entry = new ZipEntry( fileName ); // You have to give each entry a different filename
    zipOutputStream.putNextEntry( entry );
    byte buffer[] = new byte[ 1024 ]; // 1024 is the buffer size here, but it could be anything really
    int count;
    while( (count = inputStream.read( buffer, 0, 1024 ) ) != -1 ) {
        zipOutputStream.write( buffer, 0, count );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting some data from the web service and saving it in the core
Getting data from a database table to an object in code has always seemed
how can i getting data from listbox in second form named listform while i
I'm importing from a CSV and getting data roughly in the format { 'Field1'
What are the differences between using SqlDataAdapter vs SqlDataReader for getting data from a
I have the following situation. Im getting data from an external system in the
If I'm getting my data from Mysql like so: $result = $dbConnector->Query(SELECT * FROM
What is the best way of getting messages from many threads onto a queue
I'm having trouble handling a JSON object that I'm getting back from an AJAX
I'm taking my first crack at Ajax with jQuery. I'm getting my data onto

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.