java修改文件名renameTo方法
public static void main(String[] args) {
String filePath = "E:\\workspace";
String fileName = "HMGCJ-20190314152726_180712-投资公司.pdf";
String fileNameNew = "ccc.xlsx";
renameFile(filePath,fileName,fileNameNew);
}
public static void renameFile(String filePath, String fileName, String fileNameNew) {
String oldFileName = filePath+"/"+fileName;
File oldFile = new File(oldFileName);
String newFileName = filePath+"/"+fileNameNew;
File newFile = new File(newFileName);
if (oldFile.exists() && oldFile.isFile()) {
oldFile.renameTo(newFile);
}
}
在本地可以修改带中文字符的文件名,但是到linux中只能修改不带中文字符的文件名,linux手敲mv命令可以修改带中文字符的文件名,这是为啥啊?