Atitit. Software Development Concept Description--io System Area--Special file name save best practices file name encoding ... Filenameencode

Source: Internet
Author: User

Atitit. Software Development Concept Description --io System Area -- Special file name save best practices file name encoding . .. filenameencode

Not a page title saved to each file when there are invalid characters of the problem ...

Usually two processing methods::: replace into a space or use escape ( recommended ) ...

Invalid file name for Windows characters ... /\:* <>\ "| Slash, backslash, colon , asterisk , question mark , about the

Angle brackets , double quotes , tree bars ... and ..."." A point and a "..." The two points are used to denote " current directory " and " parent directory "respectively. Therefore, they also cannot be used as filenames

Linux is basically only a backslash ...

Author:: Old Wow's paw attilax Ayron, email:[email protected]

Reprint please indicate source: Http://blog.csdn.net/attilax

Public static string Filenameencode (String filenameori) {

/\:* <>\ "|

if (filenameori.equals ("." ))

return "%2e";

if (filenameori.equals (".." ) ))

return "%2e%2e";

map<string, string> MP = (map<string, string>) New closurenoexcpt () {

@Override

Public Object Execute (final object arg0) {

Final map<string, string> MP = New hashmap<string, string> () {

{

This . Put ("*", "%2a");

}

};

Final string[] as = Strutil. Splitbynone ("/\\:?<>\" | " );

for (final String s:as) {

Try  {

Mp.put (S, Urlencoder. encode (S, "Utf-8"));

} catch (final unsupportedencodingexception e) {

//  TODO auto-generated Catch block

E.printstacktrace ();

}

}

return MP;

}

}.execute (null);

string[] as = Strutil. Splitbynone (Filenameori);

String fname2 = "" ;

for (String s:as) {

fname2 + = Mp.get (s) = = NULL ? S:mp.get (s);

}

return fname2;

}

Atitit. Software Development Concept Description--io System Area--Special file name save best practices file name encoding ... Filenameencode

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.