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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:22:08+00:00 2026-06-17T17:22:08+00:00

I succeed to create gz archive with expected content, but how can I set

  • 0

I succeed to create gz archive with expected content, but how can I set the filename inside the archive?

I mean, if archive myfile.gz was created, the file inside it will be named “myfile“, but I want to name it like source file, for example, “1.txt“

Current code:

public static void gz() throws FileNotFoundException, IOException {
    GZIPOutputStream out = null;
    String filePaths[] =  {"C:/Temp/1.txt","C:/Temp/2.txt"}; 
    try {
         out = new GZIPOutputStream(
              new BufferedOutputStream(new FileOutputStream("C:/Temp/myfile.gz")));

            RandomAccessFile f = new RandomAccessFile(filePaths[0], "r");
            byte[] b = new byte[(int)f.length()];
            f.read(b);
            out.write(b, 0, b.length);

            out.finish();
            out.close();
    } finally {
         if(out != null) out.close();
    }
}
  • 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-17T17:22:09+00:00Added an answer on June 17, 2026 at 5:22 pm

    GZip compresses a stream. Typically, when people use GZip with multiple files, they also use tar to munch them together.
    gzip archive with multiple files inside

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

Sidebar

Related Questions

I am trying to create an object of Console class, but could not succeed.
I want to create an async. server. i succeed to do that, but now
How can I create multiple views inside the CREATE SCHEMA statement? I want to
I'm trying to create a basic application, i created facebook application before but everything
In Bash, I want to create a file when the command succeed, otherwise create
I was trying to find a solution but did not succeed even if it
I already spent hours on this problem, but I didn't succeed in finding a
Maybe it's a simple question but I didn't succeed to solve it. DNSperf is
the question comes basically down to this: how can i securely create new databases
When I run cap deploy , Capistrano will attempt to create a folder such

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.