如何将文件保存到类路径 [英] How can I save a file to the class path

查看:167
本文介绍了如何将文件保存到类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何保存/加载位于我的课程位置的文件?
我没有到那个位置的物理路径,我想动态地找到该文件。



谢谢

编辑:

我想加载一个XML文件,然后写入和读取它,我不知道如何解决它。

解决方案

在一般情况下,您不能。从类加载器加载的资源可以是任何东西:目录中的文件,嵌入到jar文件中的文件,甚至可以通过网络下载。


How can I save / load a file that is located where my classes are? I don't the physical path to that location before and I want dynamically to find that file.

Thanks

Edit:

I want to load an XML file and write and read to it and i am not sure how to address it.

解决方案

In the general case you cannot. Resources loaded from a classloader can be anything: files in directories, files embedded in jar files or even downloaded over the network.

这篇关于如何将文件保存到类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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