1. Get the Commons-fileupload component
Download this component in Http://jakarta.apache.org/site/downloads, unzip the file and copy Commoms-fileupload-1.2.jar to the Web-inf/lib directory
2. When using the Commons-fileupload component, another build Commoms-io support is required, which can be found on the http://jakarta.apache.org/site/downloads. Commoms-io.jar copy after download complete
To the Web-inf/
It is necessary to reduce the creation and initialization of system resource objects in the work, so think of the Apache Commons-pool Toolkit. The Commons-pool package includes three important interfaces: Objectpool is used to manage the lending and restitution of objects to be pooled; Objectpoolfactory is used to generate objectpool of the same types and settings in large quantities.
Look at the following
); + //set maximum limit for individual files -Upload.setsizemax (1024*30); + Try { A //parse all files in form form atlistupload.parserequest (request); -Iteratoritems.iterator (); - while(Iter.hasnext ()) {//process Each file in turn -Fileitem item =(Fileitem) Iter.next (); - if(!item.isformfield ()) {//file form fields -String FileName =item.getname (); in //Create a fixed-length collection by using the Aslist () me
Org. apache. commons. io -- FileUtils learning notes, fileutils
FileUtils Application
1. Write a file;
2. Read from the file;
3. Create a folder, including a folder;
4. Copy files and folders;
5. delete files and folders;
6. Get the file from the URL address;
7. list files and folders through file filters and extensions;
8. Compare the file content;
9. last modification time of the file;
10. Calculate the checksum.
1. copy a file or folder:
Example:
(httpclientparams);//In addition, set the number of retries of the HTTP client, which is 3 by default, and is currently disabled (this is the default if the project volume is not available)Httpclientparams.setparameter (Httpmethodparams.retry_handler,NewDefaulthttpmethodretryhandler (0,false)); the parameters are similar and are not explained much;Another look at the content of the reprintHttpClient 4 and HttpClient 3 set timeoutHttpClient 4:Connection timeout:Httpclient.getparams (). Setparame
Before using this toolkit, I wrote the code to execute the Linux command, because I write code to execute the Linux returned information is not complete, because it is very simple to write the call is not used to wait for the return of information, and did not implement the expiration time, and then want to implement it, but inadvertently found the toolkit, I was excited when I was able to fulfill my needs.Commons exec Download pathVersion download 1.3 version can, in fact, only one version can
Packages that need to be usedThese two packages can be downloaded on the Apache website.Commons-fileupload-1.3.1.jar is an open source project for Apache, don't talk straight.Previous section pageNote the need to addEnctype= "Multipart/form-data"Using a servletGet the uploaded files to save the directory, the uploaded files are stored in the Web-inf directory, not allow direct access to the outside world, to ensure the security of the uploaded file string savepath = This.getservletcontext (). Ge
Commons-lang record:One of the most commonly used tools, as a supplement to jdk, it is necessary to take a look at the source code ~~
Chapter 1 -- package: lang .*There are many Utils classes in Lang. * and several static methods are provided for calling, covering string operations, character operations, JVM interactive operations, classification, exception and bit field verification.
First look at the string processing class StringUtilsAll static met
normal form fields.
Public String Getfieidname ()
Returns the Name property value of a form field element
public void write (file file)
Saves the subject content saved in the Fileitem object to the specified file.
Public String getString ()
Returns the content of the theme saved in the Fileitem object as a string. Its overloaded method public arguments in the public string getString (STIRNG encoding) are encoded using the specified cha
Org. apache. hadoop. fs-Seekable, org. apache. commons
I should have read BufferedFSInputStream first, but it implements the Seekable and PositionedReadable interfaces. Let's look at these two interfaces first and then it will be easier to understand.
1 package org. apache. hadoop. fs; 2 3 import java. io. *; 4 5/** Stream that permits seeking. */6 // provides the location-based query interface 7 public interface Seekable {8/** 9 * Seek to the given
1. [Code]MD5String str = "abc"// with . NET generated MD5 method, the generated content is consistent with Java:String str = "ABC" "MD5");2. [Code]SHA1String str = "abc"// with . NET generates SHA1 in the same way that the generated content is consistent with Java:String str= "abc" "SHA1");3. [Code]BASE64// Encrypt // ABC is the string to encrypt byte true ); System.out.println (new// decryption // YWJJ for the string to decrypt BYTE[] b = base64.decodebase64 (str.getbytes ()); System.out.print
Maybe good things need to be discovered and summarized slowly.
Previously, the JSP system I wrote was solved by using the Jsp SmartUpload component.
A few days ago, the customer complained that when uploading large files, the browser did not respond, and even crashed. ask me to help solve the problem and add the upload progress representation (this temporary and no table, there is a need to add me MSN: info@hkeb.com ).
Google and baidu now, we know that JSp SmartUpload is suitable for small file
Public void fileupload (httpservletrequest request) {string uploadpath = "fileupload"; string tmppath = "tmpupload"; if (! New file (uploadpath). exists () {New file (uploadpath). mkdirs ();} If (! New file (tmppath ). exists () {New file (tmppath ). mkdirs ();} diskfileupload Fu = new diskfileupload (); Fu. setsizemax (4194304); // set the maximum file size Fu. setsizethreshold (4096); // set the buffer size Fu. setrepositorypath (tmppath); // set the temporary directory iterator it = Fu. parse
For enterprise-level applications, it is inevitable to interface with other vendors
The method for uploading XML files through WebService interfaces is not explained if there are more than two methods. However, it is still common to transmit XML data.
Normally, third-party plug-ins that Parse XML, such as dom4j, are used for parsing. You will find how complicated the XML format design is, and how complicated your parsing program will write.
Now, we can use betwixt to parse XML into a JavaBean
()){// Obtain the name of the uploaded fileString myfilename = myfile. getfilename ();// Obtain a file name without a suffixString suffix = myfilename. substring (0, myfilename. lastindexof ('.'));// Get the suffixString ext = mysmartupload. getfiles (). GetFile (0). getfileext ();// Obtain the file sizeInt filesize = myfile. getsize ();// Save pathString AA = getservletcontext (). getrealpath ("/") + "JSP //";String trace = AA + myfilename;// Obtain other parametersString explain = (string) my
Commons Lang
The document is as follows:
Http://commons.apache.org/lang/
The current version is 2.5. All classes are listed below. Click to enter the document.
ArrayutilsBitfieldBooleanutilsCharencodingCharrangeCharsetCharsetutilsCharutilsClassutilsComparetobuilderCompositeformatConstructorutilsDateformatutilsDateutilsDoublerangeDurationformatutilsEnumEnumEnumutilsEnumutilsEqualsbuilderPredictionutilsExtendedmessageformatFastdateformatFieldutilsFlo
I used to use JSON technology when I was working on a project. However, at that time, the Project Manager configured all the preparations and provided the tools, I also told us how to use it. At that time, I just thought it was very useful and I did not study it.
Today, I wrote a JSON example. The following exception is reported when a call occurs:
Java. Lang. classnotfoundexception: org. Apache. commons. Lang. Exception. nestableruntimeexception
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.