从 eclipse 中的链接文件夹中读取 java 中的文件
所以我试图读取 Eclipse Java 项目中的文件。 资源本身位于我添加的链接文件夹中:
New -> Folder. Advanced >> Link folder etc.
我无法打开该文件,因此我编写了一个简单的方法来找出我可以访问的内容:
public static void main(String[] args)
{
File folder = new File(".");
String[] listOfFiles = folder.list();
for (int i = 0; i < listOfFiles.length; i++)
{
System.out.println("file: " + listOfFiles[i]);
}
}
这给我留下了以下输出:
file: .classpath
file: .project
file: bin
那么如何打开文件在 Eclipse 中从链接的文件夹位置?
如果我不能,链接文件夹的目的是什么?
提前致谢。
So I'm attempting to read a file in an Eclipse Java project.
The resource itself is in a linked folder that I've added using:
New -> Folder. Advanced >> Link folder etc.
I couldn't open the file so I wrote a simple method to find out what I could access:
public static void main(String[] args)
{
File folder = new File(".");
String[] listOfFiles = folder.list();
for (int i = 0; i < listOfFiles.length; i++)
{
System.out.println("file: " + listOfFiles[i]);
}
}
This leaves me with the following output:
file: .classpath
file: .project
file: bin
So how do I open files in Eclipse from a linked folder location?
If I can't, what's the purpose of Linked Folders?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在运行时,您的
main
方法不知道任何 Eclipse 配置。从 Eclipse 运行它与从命令行运行它给出的结果相同。因此,由于链接的资源实际上并不存在于项目的目录中,因此您获得的输出是预期的输出。链接资源对于 Eclipse 控制的任何内容(主要是源目录或输出目录)都很有用。
At runtime, your
main
method is not aware of any Eclipse configuration. Running it from Eclipse gives the same result than running it from command line. So, since the linked resources are not physically present in the directory of your project, the ouput you get is the expected one.Linked resources can be useful for anything controlled by Eclipse (mainly source or output directories).
我能看到的唯一有效的是,如果您编辑调试配置的类路径用户条目以单击“高级...”按钮,然后单击“添加文件夹”,然后选择该文件夹,那么如果您想获取该文件,我
想您可以这样 做我认为这对于你想要的东西来说并没有多大用处。
The only thing i can see that works is if you edit your debug configuration's classpath user entries to click the Advanced... button and click add folders, and select that folder, then if you want to get that file you can do
so i suppose i don't think it's really of much use for what you want.