Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法读取包含希腊字符的路径文件_Java_File_Path - Fatal编程技术网

Java 无法读取包含希腊字符的路径文件

Java 无法读取包含希腊字符的路径文件,java,file,path,Java,File,Path,我面临的问题是,如果文件存储在包含希腊字符的税务箱文件夹中,则无法读取 我们将文件路径作为输入,只要文件路径中包含希腊字符,我的代码就会失败 给定错误 java.nio.file.NoSuchFileException:E:\strsWorkÎu Dev\ΕÎÎΧ10017606 代码如下: private void registerDirectory(Path path) throws IOException { WatchKey key = path.register(wa

我面临的问题是,如果文件存储在包含希腊字符的税务箱文件夹中,则无法读取

我们将文件路径作为输入,只要文件路径中包含希腊字符,我的代码就会失败

给定错误

java.nio.file.NoSuchFileException:E:\strsWorkÎu Dev\ΕÎÎΧ10017606

代码如下:

   private void registerDirectory(Path path) throws IOException {

   WatchKey key = path.register(watchService, new WatchEvent.Kind[]{
            StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE
        }, SensitivityWatchEventModifier.HIGH);
        LOGGER.debug("registerDirectory adding path " + path.toString());
        keys.put(key, path);
    }

听起来像是编码问题。您必须以正确的字符结束。在源代码中硬编码名称时是否有效?是的,在源代码和字符串不包含任何希腊字符时有效,因此在path变量中,如果包含希腊字符,则失败。您熟悉吗?您好,有人能帮我解决这个问题吗?看看你在硬编码字符串和传入字符串时手里有多少字节。String.getBytes是您的朋友。