close stream for IO.resourceExist

This commit is contained in:
Timi
2025-07-23 11:13:23 +08:00
parent 3effab4def
commit f9d7221e0f

View File

@ -909,8 +909,13 @@ public class IO implements OS.FileSystem {
* @param path jar 内文件路径,不需要 / 开始,如 config/TimiJava.ini
* @return 数据流
*/
public static boolean resourceExist(Class<?> clazz, String path) {
return resourceToInputStream(clazz, path) != null;
public static boolean resourceExist(Class<?> clazz, String path) throws IOException {
InputStream stream = resourceToInputStream(clazz, path);
if (stream != null) {
stream.close();
return true;
}
return false;
}
/**