{"record":{"id":"75c1f89c5f165add","repo":"chinabugotech/hutool","slug":"can-not-read-file-path-of","errorCode":null,"errorMessage":"Can not read file path of [{}]","messagePattern":"Can not read file path of \\[(.+?)\\]","errorType":"exception","errorClass":"IORuntimeException","httpStatus":null,"severity":"error","filePath":"hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java","lineNumber":265,"sourceCode":"\t\t\tfinal List<String> paths = new ArrayList<>();\n\t\t\tfinal File[] files = ls(path);\n\t\t\tfor (File file : files) {\n\t\t\t\tif (file.isFile()) {\n\t\t\t\t\tpaths.add(file.getName());\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn paths;\n\t\t}\n\n\t\t// jar文件中的路径\n\t\tindex = index + FileUtil.JAR_FILE_EXT.length();\n\t\tJarFile jarFile = null;\n\t\ttry {\n\t\t\tjarFile = new JarFile(path.substring(0, index));\n\t\t\t// 防止出现jar!/cn/hutool/这类路径导致文件找不到\n\t\t\treturn ZipUtil.listFileNames(jarFile, StrUtil.removePrefix(path.substring(index + 1), \"/\"));\n\t\t} catch (IOException e) {\n\t\t\tthrow new IORuntimeException(StrUtil.format(\"Can not read file path of [{}]\", path), e);\n\t\t} finally {\n\t\t\tIoUtil.close(jarFile);\n\t\t}\n\t}\n\n\t/**\n\t * 创建File对象，相当于调用new File()，不做任何处理\n\t *\n\t * @param path 文件路径，相对路径表示相对项目路径\n\t * @return File\n\t * @since 4.1.4\n\t */\n\tpublic static File newFile(String path) {\n\t\treturn new File(path);\n\t}\n\n\t/**\n\t * 创建File对象，自动识别相对或绝对路径，相对路径将自动从ClassPath下寻找","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/chinabugotech/hutool/blob/8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L247-L283","documentation":"When listFileNames resolves a path containing the JAR path extension marker (e.g. \"/path/to/x.jar!/com/foo\"), it opens it as a JarFile and lists the inner entries. If opening or reading the JAR throws IOException, it is wrapped and rethrown as IORuntimeException(\"Can not read file path of [{}]\").","triggerScenarios":"Calling a file-name listing method on a path with a \".jar!\" marker where the JAR is missing, corrupt, truncated, locked, or the inner entry path is malformed.","commonSituations":"Corrupt or partially-downloaded JAR; JAR deleted between path resolution and read; a path that coincidentally contains \".jar!\" but is not a real JAR; permission/lock preventing the JarFile constructor from opening it.","solutions":["Verify the JAR portion of the path exists and is a readable file before listing.","Confirm the path genuinely uses the \".jar!/entry\" convention and is not a false match.","Catch IORuntimeException, inspect getCause() for the underlying IOException, and report the specific JAR path."],"exampleFix":"// before\nList<String> names = FileUtil.listFileNames(\"/app/lib/bad.jar!/cn/hutool\");\n\n// after: confirm the jar exists first\nString jarPart = \"/app/lib/bad.jar\";\nif (FileUtil.isFile(jarPart)) {\n    List<String> names = FileUtil.listFileNames(jarPart + \"!/cn/hutool\");\n}","handlingStrategy":"try-catch","validationCode":"String jarPart = path.substring(0, path.lastIndexOf(\".jar!\") + 4);\nif (!FileUtil.isFile(jarPart)) {\n    // JAR missing/unreadable: do not attempt to list\n}","typeGuard":"static boolean isReadableJarPath(String path) {\n    int i = path.lastIndexOf(\".jar!\");\n    if (i < 0) return false;\n    File jar = new File(path.substring(0, i + 4));\n    return jar.isFile() && jar.canRead();\n}","tryCatchPattern":"try {\n    return FileUtil.listFileNames(jarPath);\n} catch (IORuntimeException e) {\n    Throwable cause = e.getCause(); // underlying IOException\n    // report which JAR could not be read; treat as missing resource\n}","preventionTips":["Confirm the JAR portion of a \".jar!/entry\" path exists and is readable before listing.","Watch for paths that merely contain \".jar!\" but are not real JARs.","Inspect getCause() for the real IOException when diagnosing."],"tags":["io","jar","file"],"backgroundTag":null,"analyzedSha":"8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442","analyzedAt":"2026-08-14T04:01:12.892Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}