具有Linux操作系统中不能访问的具有空格字符的文件名。正在获取FileNotFoundException

问题描述 投票:0回答:1

String fileName =“这是我的file.txt”;字符串路径=“ / home / myUsername / folder /”;

String filePath =路径+文件名;f = new BufferedInputStream(new FileInputStream(filePath));

java linux file exception filenotfoundexception
1个回答
0
投票

尝试使用路径之前先对其进行解码。

String decodedPath = URLDecoder.decode(path, "UTF-8");
© www.soinside.com 2019 - 2024. All rights reserved.