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 6151599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:47:31+00:00 2026-05-23T19:47:31+00:00

I am trying to load some GZIP-ed data from a resource in my .jar,

  • 0

I am trying to load some GZIP-ed data from a resource in my .jar, but I get a java.io.IOException: Not in GZIP format message.

When I load the same data from a file, I don’t get any error. Why? (It is a maven project I compile with NetBeans)

Here is the test code generating the issue:

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

    byte[] dummy = new byte[10];

    // Reading data from file
    File f = new File("C:\\Temp\\422\\convert1900.data");
    DataInputStream is = new DataInputStream(
            new GZIPInputStream(new FileInputStream(f)));

    while ( is.read(dummy) != -1 );

    // Reading data from resource
    InputStream ins = CompareTest2.class.getResourceAsStream(
            "/net/cv/convert1900.data");

    is = new DataInputStream(
        new GZIPInputStream(ins)); // Issue happens here

    while ( is.read(dummy) != -1 );

}

EDIT

Both ‘files’ have the same content.

EDIT 2

I just tried to count the number of bytes I get with both methods using the following code:

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

    int total = 0;
    int retr = 0;

    byte[] dummy = new byte[10];

    // Reading data from file
    File f = new File("C:\\Temp\\422\\convert1900.data");
    InputStream is = new FileInputStream(f);

    do {
        retr = is.read(dummy);
        if ( retr != -1 )
            total += retr;
    } while ( retr != -1 );

    System.out.println("Total file: " + total);

    // Reading data from resource
    InputStream ins = CompareTest2.class.getResourceAsStream(
            "/net/cv/convert1900.data");

    total = 0;
    retr = 0;

    do {
        retr = ins.read(dummy);
        if ( retr != -1 )
            total += retr;
    } while ( retr != -1 );

    System.out.println("Total resource: " + total);

}

and I get:

Total file: 9132744
Total resource: 16399085

Very strange !!

EDIT 3

I have just noticed the size of the resource in the .jar is 16399085 (uncompressed) instead of 9132744. It seems that the issue is in the compilation process.

May be I have an issue with the following in my pom.xml:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <encoding>${project.build.sourceEncoding}</encoding> // UTF8
            </configuration>
        </plugin>
  • 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-23T19:47:32+00:00Added an answer on May 23, 2026 at 7:47 pm

    My issue lied in the filtering of my resources. A solution is available here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to load some returned html from an .aspx page but a
I'm trying to load some data via. jquery $get_desc = SELECT tekst_id,overskrift FROM rr_tekster
I'm trying to load some decimal values from a file but I can't work
I am trying to load some data from a text file into a vector
I am trying to load some data into R from an Access database. All
I am trying to load some data from a text file into mysql. I
In the NodeMouseClick event I'm trying to load some objects from the Node.Tag. Before
I'm trying to make a request using dojo.xhrGet to grab some XML data from
I'm trying to load some java stored procedures into an Oracle 10g database through
I'm trying to load some data using sql loader. Here is the top of

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.