How to read 'List separator' from OS in Ja

2019-01-27 20:31发布

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.

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.

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.

7条回答
来,给爷笑一个
2楼-- · 2019-01-27 21:20

From comments of this answer:

Reading the OS-specific setting is a need I have to meet.

So what if OSs other than Windows don't have such a setting?

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.

查看更多
登录 后发表回答