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