I run the code well when the file path is all English or Chines,but When my file path has both Chinese and English, the code result is false.In my window system,I try to encode the file path,and it runs well.But when I try to deploy it in the Linux system,It return false,the file path is:/home/file/GPRS核心.zip. How to fix my code?
//the first version
new File(fileName).exists()
//the second version
new File(new String(fullFileName.
getBytes(StandardCharsets.ISO_8859_1))).exists()
//the third version:return true in window and return false in linux
new File(new String(fullFileName.
getBytes(StandardCharsets.UTF_8))).exists()
The linux encode is here:
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=