FileInputStream 在哪个文件夹中查找? [英] In which folder is FileInputStream looking?

查看:34
本文介绍了FileInputStream 在哪个文件夹中查找?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用线

FileInputStream stream = new FileInputStream("myfile.properties");

在不指定路径的情况下打开属性文件.

to open a properties file without specifying a path.

在 Apache Tomcat 上运行时,找不到该文件.我将文件放入应用程序的根文件夹中.

When running it on Apache Tomcat, the file can not be found. I placed the file into the root folder of the application.

Java 在哪个文件夹中查找?

In which folder is Java looking?

我无法更改路径,因为代码不是我的.

I can not change the path because the code is not by me.

推荐答案

它会在文件夹中查找

System.getProperty("user.dir")

这可能在任何地方.这取决于tomcat服务器启动时的当前工作目录.

and this could be anywhere. That depends the current working directory when the tomcat server is started.

如果您无法从标准日志或 tomcat 启动过程中找出答案,请尝试加载一个小的 servlet,在加载时打印该信息.

Try to load a small servlet that prints that info at loading if you cannot figure out from standard logs or the tomcat start procedure.

这篇关于FileInputStream 在哪个文件夹中查找?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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