如何在Red5中获取应用程序路径(绝对和相对)
我制作了一个应用程序并将其作为新文件夹放入 webapps 中,例如 appcustom。
我想阅读一些文本文件。
我如何一般地读取而不是硬编码路径?
目前我正在使用这样的东西:
FileReader fr = new FileReader("webapps/appcustom/<<textfilename>>"); // read a file
如何使其通用?因为明天我可能想将应用程序文件夹名称更改为“custApp”或其他名称。
I made a application and placed it in webapps as new folder, say appcustom.
There are some text files that I want to read.
How do I generically read rather than hardcoding the path?
Currently I am using something like this:
FileReader fr = new FileReader("webapps/appcustom/<<textfilename>>"); // read a file
How do I make it generic? Because tomorrow I may want to change the application folder name to "custApp" or something else.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在 Red5 中使用一些系统属性,如果我尝试从通用应用程序类读取资源,我将使用此块:
需要提供应用程序名称(例如:oflaDemo)和您的文件名。
从 ApplicationAdapter 中,您可以访问“可用”应用程序名称:
从 Servlet 中,您可以访问完整路径:
There are a few system properties that you can use in Red5, I would use this block if I were attempting to read a resource from a generic application class:
The application name (ex: oflaDemo) and your file name would need to be supplied.
From an ApplicationAdapter you have access to a "usable" application name:
From an Servlet you have access to a full path:
我发现这种方式对于阅读任何文件都非常有帮助。
这是完整示例的链接
I found this way very helpfull in reading any file.
Here is the link of full example
您可能需要检查Streaming_from_custom_directories
You may want to check this Streaming_from_custom_directories