//a jar package can contain multiple entry so that the following functions can be implemented1.i/O Read file stream step file file=NewFile (FilePath); InputStreamReader Read=NewInputStreamReader (Newfileinputstream (file)); BufferedReader BufferedReader=NewBufferedReader (read); String Linetxt=Bufferedreader.readline () PackagePlayjar;/*** Read the path file in TXT file *@authorGJF*/ImportJava.io.BufferedReader;ImportJava.io.File;ImportJava.io.FileInputStream;ImportJava.io.InputStreamReader;Importjava.util.ArrayList;Importjava.util.List; Public classreadfile{ Public StaticList<string>Readtxtfile () {String FilePath= "E:/jar/prpall.txt"; List<String> list =NewArraylist<string>(); Try{File File=NewFile (FilePath); if(File.isfile () && file.exists ()) {//determine if a file existsInputStreamReader Read=NewInputStreamReader (Newfileinputstream (file)); BufferedReader BufferedReader=NewBufferedReader (read); String Linetxt=NULL; while((Linetxt = Bufferedreader.readline ())! =NULL) {List.add ("e:/Operations Domain/baseline domain 04-b/prpall/modules/webapps/" +linetxt); } System.out.println ("List" +list); Read.close (); }Else{System.out.println ("The specified file cannot be found"); } }Catch(Exception e) {System.out.println ("Error reading file contents"); E.printstacktrace (); } returnlist; }} PackagePlayjar;ImportJava.io.File;ImportJava.io.FileInputStream;ImportJava.io.FileOutputStream;Importjava.io.IOException;ImportJava.util.jar.JarEntry;ImportJava.util.jar.JarOutputStream;/*** Package The path file in a single txt *@authorPC*/ Public classPjar { Public Static voidMain (string[] args)throwsIOException {fileinputstream fis=NULL; Jaroutputstream Jos=NULL; Jos=NewJaroutputstream (NewFileOutputStream ("E:/jar/ppp.jar")); for(String s:readfile.readtxtfile ()) {File File=NewFile (s);//file AddressFIS=Newfileinputstream (file); //Create an entry in a compressed file, substring to intercept the previous pathjarentry enttry=NewJarentry (File.getpath (). SUBSTRING (38)); System.out.println ("Create an entry in a compressed file:" +enttry); //Add the created entries to the compressed filejos.putnextentry (enttry); //write the specific contents of the current entry byte[] Buff =New byte[1024]; intLen = 0; while(len = fis.read (buff))! =-1) {jos.write (buff,0, Len); }} fis.close (); Jos.close (); }}
Java Play War package or hit jar package