Search code examples
javalocaleprintstream

Changing Locale of a printstream in Java


I'm working on a project in which you can draw lines on a canvas and save it in a textfile with coordinates for each line.

However, when I try to save it with this method, and write it to the textfile, all dots are replaced by commas.

I assume this is due to my language on the PC being European, so I've tried to find a workaround by setting the Locale of the printstream to Locale.US, but without luck.

How can I possibly fix this without changing the language of my entire PC?


Solution

  • Update: I fixed this by changing the Locale in my 'main' method:

    Locale.setDefault(new Locale("en", "US"));