[英](Java) How do you do full paths in the File class when you are using Textmate in a macbook?
我有一台 macbook,如果我們沒有電腦,我們學校告訴我們使用 TextMate。 我可以在 pc 上做到這一點,但我在 mac OS 中遇到了語法問題,因為它們是不同的。 這就是我正在使用的,即使我創建了一個名為Data.txt
的文件,彈出的提示說它不存在。
import java.io.File;
class FileClassTutorial
{
public static void main(String[]args)
{
File x= new File("MacintoshHD/Users/Alexis/Desktop/Data.txt");
if(x.exists())
System.out.println(x.getName() + " exists!!!");
else
System.out.println("This file doesn't exist");
}
}
new File("something/other"
) 被假定為 "./something/other" 其中 '.' 是啟動 jvm 的當前工作目錄。 這是你需要的嗎?
否則,您可以以“/”開頭的路徑從文件磁盤的超級根目錄獲得絕對路徑
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.