簡體   English   中英

Java System.getProperty(“user.home”)

[英]Java System.getProperty(“user.home”)

在這行代碼中,我使用了getProperty方法:

PrintWriter writer = new PrintWriter("~/4413/ctrl/geo.txt".replaceFirst("^~", System.getProperty("user.home")), "UTF-8");

結果是C:UsersKamel\4413\ctrl\geo.txt缺少一些\分隔符,這不完全是我想要的。

我可以添加什么以使路徑正確嗎?

引用System.getProperty("user.home")

Matcher.quoteReplacement(System.getProperty("user.home"))

問題是replaceFirst的兩個參數都以特殊方式處理字符,因為您處理的是正則表達式,而不是文字字符串。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM