Home > Back-end >  About the Tar bag packaging path problem
About the Tar bag packaging path problem

Time:12-03

 
Public static File pack (List Sources, the File target) {
FileOutputStream out=null;
Try {
Out=new FileOutputStream (target);
{} the catch (FileNotFoundException e1)
E1. PrintStackTrace ();
}
TarArchiveOutputStream OS=new TarArchiveOutputStream (out);
For (the File File: sources) {
Try {
System. The out. Println (file. The getName ());
OS. PutArchiveEntry (new TarArchiveEntry (file));
IOUtils. Copy (new FileInputStream (file), OS).
OS. CloseArchiveEntry ();

} the catch (FileNotFoundException e) {
e.printStackTrace();
} the catch (IOException e) {
e.printStackTrace();
}
}
If (OS!=null) {
Try {
OS. The flush ();
OS. The close ();
} the catch (IOException e) {
e.printStackTrace();
}
}

Return target;
}

The above is what I use packaging code, but I want to directly after packaging bag is file inside, without any path, could you tell me how to modify the address,

Can see the packaging file folder, there are a lot of layer after but I want to open the buns are the three files should be how to modify, strives for the great god grant instruction,

CodePudding user response:

https://blog.csdn.net/keepTravel/article/details/78132323
Look at this

CodePudding user response:

reference 1st floor welan123123 response:

https://blog.csdn.net/keepTravel/article/details/78132323Look at the

If does not solve my problem

CodePudding user response:

Then copy all files to a folder to download again

CodePudding user response:

reference welan123123 reply: 3/f
then copy all files to a folder to download

Yo files in a folder, I here also have no download, is a simple packaging

CodePudding user response:

reference 4 floor qq_21728705 response:
Quote: reference welan123123 reply: 3/f

Then copy all files to a folder to download

Yo files in a folder, I here also have no download, is a simple packaging

To remove a folder copy, after the completion of the packaging to delete the folder; Or you do not say what is the path of a subfolder?

CodePudding user response:

reference 5 floor welan123123 reply:
Quote: refer to 4th floor qq_21728705 response:

Quote: refer to the third floor welan123123 response:

Then copy all files to a folder to download

Yo files in a folder, I here also have no download, is a simple packaging

To remove a folder copy, after the completion of the packaging to delete the folder; Or you do not say what is the path of a subfolder?

This package is under Linux system running, is not the root, cannot put files in the root directory

CodePudding user response:

refer to 6th floor qq_21728705 response:
Quote: refer to the fifth floor welan123123 reply:

Quote: refer to 4th floor qq_21728705 response:

Quote: refer to the third floor welan123123 response:

Then copy all files to a folder to download

Yo files in a folder, I here also have no download, is a simple packaging

To remove a folder copy, after the completion of the packaging to delete the folder; Or you do not say what is the path of a subfolder?

This package is under Linux system running, is not the root, cannot put files in the root directory

Pack may not be the root directory, then remove to ah

CodePudding user response:


Close test can meet the needs of the building Lord, I also gathers up the another god, ha ha,,,
The original link: https://blog.csdn.net/qq804702802/article/details/47829859

CodePudding user response:

Can be added below the second line of code:
 TarArchiveEntry scavenged=new TarArchiveEntry (file); 
Airport. Elegantly-named setName (file. The getName ());
OS. PutArchiveEntry (it);

CodePudding user response:

refer to 12 floor dq5211 reply:
add below the second line of code can be:
 TarArchiveEntry scavenged=new TarArchiveEntry (file); 
Airport. Elegantly-named setName (file. The getName ());
OS. PutArchiveEntry (it);

The original poster can be posted
"Kiss can measure!!!!!!!!!!!

CodePudding user response:

refer to 12 floor dq5211 reply:
add below the second line of code can be:
 TarArchiveEntry scavenged=new TarArchiveEntry (file); 
Airport. Elegantly-named setName (file. The getName ());
OS. PutArchiveEntry (it);

Fortunately, click the next button, or you need to check for a while again,,
Eldest brother cow force, to take root hanako!
  • Related