Linux 如何知道ubuntu中文件夹的绝对路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13263989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to know the absolute path of folder in ubuntu
提问by Adarsh
I made a java application in NetBeans on Windows which I need to deploy on Ubuntu. In my java application I have given the path where an excel file will get saved on the click of the button. My address path is like this D://Excel. This is working fine in windows and file is getting saved at the given passed address. Now my problem is this i don't know how can I get the address path in ubuntu. Any help will be highly appreciated.
我在 Windows 上的 NetBeans 中创建了一个 java 应用程序,我需要在 Ubuntu 上部署它。在我的 java 应用程序中,我给出了单击按钮时将保存 excel 文件的路径。我的地址路径是这样的 D://Excel。这在 Windows 中工作正常,文件被保存在给定的传递地址。现在我的问题是我不知道如何在 ubuntu 中获取地址路径。任何帮助将不胜感激。
采纳答案by Konza
take your terminal and type
拿起你的终端并输入
pwd
This will give your home folder path. Use that in your program.. It will be something like this /home/adarsh..
这将提供您的主文件夹路径。在你的程序中使用它......它会是这样的 /home/adarsh..
回答by Bhavesh Shah
The question seems like : How to construct a relative path in Java from two absolute paths (or URLs)?
问题似乎是:如何从两个绝对路径(或 URL)构造 Java 中的相对路径?
Please refer above link. Hope this helps you.
请参考上面的链接。希望这对你有帮助。