問題描述
我正在用 Java 編寫一個 CSV 導出器,它應該尊重用戶的自定義設置,尤其是用作分隔符的列表分隔符".
I am writing a CSV exporter in Java that should respect the user's custom settings, especially the "List separator" to use as a delimiter.
在 Windows 中,可以設置此列表分隔符
In Windows, one can set this List separator in
Control Panel -> Regional and Language Options -> Regional Options -> Customize
我不了解其他操作系統,但我很確定您也可以在其他操作系統上進行更改.
I don't know about the other operating systems, but I'm pretty sure that you can change that on other OSes, too.
將此自定義設置從操作系統導入 Java 的最佳方法是什么?我在 Eclipse RCP 環境中,所以如果有可用的東西,我可能會使用 RCP 相關的解決方案.
What is the best way to get this custom setting from the OS into Java? I am in an Eclipse RCP environment, so I might use RCP-related solutions if there is something available.
推薦答案
來自 這個答案:
閱讀特定于操作系統的設置是我必須滿足的需求.
Reading the OS-specific setting is a need I have to meet.
如果 Windows 以外的操作系統沒有這樣的設置怎么辦?
So what if OSs other than Windows don't have such a setting?
我建議你從 Windows 上的注冊表中讀取它(正如提到的 這里):讀/寫到Windows注冊表使用 Java.在其他平臺上,只需使用一個好的默認值,也許,至少在 Unix 上,還支持通過自定義環境變量(您記錄得很好)來配置它:我的 java 代碼如何讀取操作系統環境變量?.
I suggest you read it from registry on Windows (as alluded here): Read/write to Windows Registry using Java. On other platforms just use a good default, and perhaps, at least on Unix, also support configuring it via a custom environment variable (which you document well): How can my java code read OS environment variables?.
我的直覺認為操作系統普遍沒有(系統范圍或用戶特定的)列表分隔符"設置,當然,這可能是錯誤的,但我對此表示懷疑.
My gut feeling that OSs universally do not have a (system-wide or user-specific) "List separator" setting may be wrong, of course, but I doubt that.
這篇關于如何從 Java 中的操作系統讀取“列表分隔符"?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!