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

  • Home
  • SEARCH
  • 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 7975629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:41:42+00:00 2026-06-04T08:41:42+00:00

Here the main functionality of my web application is to upload .zip file and

  • 0

Here the main functionality of my web application is to upload .zip file and store it at the server side but before doing that I need to do some following task:
1.) .zip file contains the xml file, I have to first validate the xml file using schema.
2.) if the xml file is valid than I need to convert the content of the xml file into string without unzipping the file i.e. from the inputstream.

I am successfull in validating the xml file but I am getting the following exception while converting the string from the inputstream:
“java.io.EOFException: Unexpected end of ZLIB input stream”

I have tried all the solutions provided in the Stack Overflow and other forum site but I am not yet successfull. Any help will be really appreciated:

Following is the code:

try
    {
        ZipFile zipFileUtil = new ZipFile(zipFile);
        Enumeration<? extends ZipEntry> zipFileContents = zipFileUtil.entries();
        while(zipFileContents.hasMoreElements())
        {

            ZipEntry zipEntry = zipFileContents.nextElement();
            if(zipEntry.getName().equals("File.xml"))
            {
                InputStream sourceFile = zipFileUtil.getInputStream(zipEntry);
                if(isValidAsPerXSD(sourceFile))
                {
                    //At this line Exception is Generated
                    String xmlContent = IOUtils.toString(sourceFile);
                }
            }
        }

    }
    catch(Throwable t)
    {
        System.out.println("Exception: "+t.getMessage());
    }
  • 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-06-04T08:41:44+00:00Added an answer on June 4, 2026 at 8:41 am

    You cannot read the stream “sourceFile” twice !
    An input stream is supposed to be read sequentially to the end. You must close it and reopen it.

    InputStream sourceFile = zipFileUtil.getInputStream(zipEntry);
    if(isValidAsPerXSD(sourceFile))
    {
        sourceFile.close();
        sourceFile = zipFileUtil.getInputStream(zipEntry);
        //At this line Exception is Generated
        String xmlContent = IOUtils.toString(sourceFile);
    }
    sourceFile.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need the functionality of AWT Frames for one component, but my main application
here's the main code at first I thought is was the message box but
What am I doing wrong here: class Helo { // main: generate some simple
I am working on asp.net, C# web application. Working on my main page in
I need to add GPS functionality to an existing Blackberry Application that I've written.
I am attempting to create functionality in a JSF1.2/ADF web app that will periodically
Here is my main page code: <form><iframe name=iframe_pic src=iframe.html></iframe></form> Here is my iframe.html: <script
Here's the main question I guess : Is there a .NET way to get
I'm looking for a way to monitor system statistics. Here are my main points
// Here's my code: Main Class: import java.awt.*; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.awt.image.BufferStrategy;

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.