Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read 'List separator' from OS in Java?

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.

like image 834
Simon07 Avatar asked May 08 '09 07:05

Simon07


2 Answers

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.

like image 60
Jonik Avatar answered Oct 26 '22 23:10

Jonik


Without resorting to a platform specific solution I think that the best approach to take is going to be to allow users to specify their preference of list separator within your own application. Either in a preferences panel, a dialog box on export or via an optional command line argument.

like image 45
ninesided Avatar answered Oct 27 '22 01:10

ninesided