Collection of useful tools in Spring 3

Source: Internet
Author: User
Tags md5 encryption object serialization
1) Request tool class org. springframework. Web. Bind. servletrequestutils // Obtain the integer of the request parameter: public static integer getintparameter (servletrequest request, string name) public static int getintparameter (servletrequest request, string name, int defaultval) --> Single value Public static int [] getintparameters (servletrequest request, string name) --> Array For example Long, float, double, Boolean, string . 2) string tool class org. springframework. util. stringutils Uppercase: public static string capitalize (string Str) lowercase: public static string uncapitalize (string Str) judge whether the string is null or empty: public static Boolean haslength (string Str) judge whether the string is a non-blank string (that is, a string containing at least one non-space): Public static Boolean hastext (string Str) Get the file name: public static string getfilename (string path) such as e.g. "mypath/myfile.txt"-> "myfile.txt" get the file extension: public static string getfilenameextension (string path) such as "mypath/ Myfile.txt "->" TXT "also includes array-to-set, set-to-array, path processing, string splitting into arrays, array or set merging into strings, array merging, adding elements to arrays, etc.. 3) Object serialization and deserialization org. springframework. util. serializationutils Public static byte [] serialize (Object object) public static object deserialize (byte [] bytes) 4) digital processing org. springframework. util. numberutils The string is converted to a number and formatted, including the specific number implementation classes, such as long, integer, and double. The string supports a hexadecimal string, and spaces in the string are automatically removed: public static <t extends number> T parsenumber (string text, class <t> targetclass) public static <t extends number> T parsenumber (string text, class <t> targetclass, Numberformat Numberformat) conversions in various numbers, such as long for integer, automatically handle number overflow (throwing an exception): Public static <t extends number> T convertnumbertotargetclass (Number, class <t> targetclass) 5) copy the org. springframework. util. filecopyutils file. Stream-to-stream, stream-to-string, byte array-to-stream Replication 6) Directory ReplicationOrg. springframework. util. filesystemutils Recursively copy and delete a directory
7) MD5 EncryptionOrg. springframework. util. digestutils MD5 encryption of byte arrays public static string md5digestashex (byte [] bytes)

 

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.