通过代码从当前运行的 JAR 中提取文件 [英] Extracting a file from the currently running JAR through code

查看:21
本文介绍了通过代码从当前运行的 JAR 中提取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何内置方法可以让用户从当前运行的 JAR 中提取文件并将其保存在他们的磁盘上?

Are there any built-in methods I can use to allow users to extract a file from the currently running JAR and save it on their disk?

提前致谢.

推荐答案

使用 getResourceAsStream (docs),之后你可以用它做任何你想做的事情.

Use getResourceAsStream (docs), you can do whatever you want with it after that.

对于两线,你可以使用 Commons IO 复制方法之一.

For a two-liner you could use one of the Commons IO copy methods.

这篇关于通过代码从当前运行的 JAR 中提取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆