android will report an error when the file name is in Chinese and space
- 2020-05-07 20:27:35
- OfStack
The file name is in Chinese and there are Spaces. If you don't process the connection, you'll get an error. To solve this problem, you just encode your url and replace the Spaces with the code
The above method can be used to handle the cases of Chinese and white space when downloading links and if there are other special characters can be used to solve this method
// Code the path Then replace all the Spaces in the path After coding, the space becomes" + "And the code for a space is" %20 " So all the" + "Instead of" %20 "Will do
url = URLEncoder.encode(urlStr,"utf-8").replaceAll("\\+", "%20");
// In the encoded path. / "Has also become a coded thing All of that and replace it back That's the full path
url = url.replaceAll("%3A", ":").replaceAll("%2F", "/");
The above method can be used to handle the cases of Chinese and white space when downloading links and if there are other special characters can be used to solve this method