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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:37:22+00:00 2026-06-15T23:37:22+00:00

Windows – I am trying to create a new Tar file with with the

  • 0

Windows – I am trying to create a new Tar file with with the JTar lib with the following inside…

MyTarFile.tar--|
               |--MyFolder--|
                            |--MyFile.zip

I can create it with the folder and the zip file right in the root of MyTarFile but I don’t know (and I looked around) how to create that folder AND have the zip file inside. I need to know what to use (the File object(s)) for the TarEntry(s) (is it one for folder and one for file…or one for both?) and what the InputStream should look like (I believe just a single one for the zip file but not sure). I am trying to create a file to mimic an existing format so I don’t have the option of just losing that folder as the software that uses the file will be looking for it. I can add the zip file to the MyFolder folder on the actual file system (again, this is on Windows) before tarring or not…whatever works is fine.

I have tried full paths and relative paths (seems the InputStream MUST have a full path though) with no luck. Running out of ideas other than switching libraries (perhaps JTar doesn’t support this).

Thanks!

  • 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-15T23:37:23+00:00Added an answer on June 15, 2026 at 11:37 pm

    Without seeing what you have already written, here is my best attempt at answering. I am unfamiliar with JTar, but after taking a look at the example on their main page, I wrote a quick test program that created a tar with one file in the root of the tar and one file in a directory in the tar, which I believe is what you are attempting to do. The code of interest to you is this:

    TarEntry tarEntry = new TarEntry(new File("/Users/userGuy/Documents/students.xml"),"students.xml");
    TarEntry otherTarEntry = new TarEntry(new File("/Users/userGuy/Documents/students2.xml"),"inner-dir/students2.xml");
    

    Note that the second tar entry, otherTarEntry is instantiated with a relative path as the entryName argument in the TarEntry constructor. This is a poorly named argument, as it is technically the path of the file in the tar, not just the name.

    With your example file names above, your code might look something like this:

    TarEntry tarEntry = new TarEntry(new File("<path to file>"),"MyFolder/MyFile.zip");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Windows 7, 64bit, MinGW toolset, following code: m_data = reinterpret_cast<SampleType *>(realloc(m_data, m_size + v));
Windows phone performance analysis creates a file with .sap extension. This .sap file is
Windows already contains dialogs to choose a file or printer. Is there a built-in
Windows command line, I want to search a file for all rows starting with:
Windows explorer in XP will allow you to make a file selection based on
Windows Vista - using the following plugins - Codesmith and CodeKeep. I quess it
Windows 7 has a (neat?) new feature called a 'virtual wireless adapter'. Read about
Windows Vista added a new feature called the Secure Desktop. It looks great and
Windows fails to pick up my .hgignore file. I'm running Mercurial from the command
Windows 7 Aero Theme has a brand new taskbar with extensions . What is

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.