URLUtil.java 文件源码

java
阅读 36 收藏 0 点赞 0 评论 0

项目:intellij-ce-playground 作者:
@NotNull
private static InputStream openJarStream(@NotNull URL url) throws IOException {
  Pair<String, String> paths = splitJarUrl(url.getFile());
  if (paths == null) {
    throw new MalformedURLException(url.getFile());
  }

  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") final ZipFile zipFile = new ZipFile(FileUtil.unquote(paths.first));
  ZipEntry zipEntry = zipFile.getEntry(paths.second);
  if (zipEntry == null) {
    zipFile.close();
    throw new FileNotFoundException("Entry " + paths.second + " not found in " + paths.first);
  }

  return new FilterInputStream(zipFile.getInputStream(zipEntry)) {
    @Override
    public void close() throws IOException {
      super.close();
      zipFile.close();
    }
  };
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号