Detailed examples of java file upload

Detailed examples of java file upload

Java file upload

Java file upload introduces several common methods, which have been debugged by myself

1.jspsmartupload

This component is very convenient to use, but it is only suitable for uploading small files. If you upload large files, it won't work. I checked his code, M_ totalBytes = m_ request. getContentLength(); m_ binArray = new byte[m_totalBytes]; The whole uploaded file is actually read into the memory. If you upload tens of MM files and several users upload them at the same time, the server will hang stably. However, if you only upload small files within 5m, this component is still very practical

Here is the source code:

File class

Files class

Request class

SmartUpload class

Smartuploadexception class

Uploaded Servlet

2. Common fileUpload component

It's very useful. It can also upload large files. I've tried. Files above 300m can be uploaded very quickly locally, and remote tests can also be uploaded successfully

First, Download org apache. commons. FileUpload package and org apache. commons. IO package

Here is my servlet

If you have any questions, please leave a message or go to the community of this site for exchange and discussion. Thank you for reading. I hope it can help you. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>