Java Play War package or hit jar package

Source: Internet
Author: User
Tags readfile

//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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.