This is my first question and it may sound stupid, but I can't find a solution. I'm learning Java, and I was doing an exercise that reads a txt from the internet with temperatures in double format in it (i.e 86.60).
The problem is, after correctly compiling it, when I tried to run it I got the following exception:
Exception in thread "main" java.util.InputMismatchException
This is the method in question:
public static double[] arrayFromUrl(String url) throws Exception {
Scanner fin = new Scanner((new URL(url)).openStream());
int count = fin.nextInt();
double[] dubs = new double[count];
for ( int i=0; i<dubs.length; i++)
dubs[i] = fin.nextDouble();
fin.close();
return dubs;
}
And this is the target file: https://learnjavathehardway.org/txt/avg-daily-temps-atx.txt
I finally figured out it was because of the format of the entries, my powershell doesn't accept doubles in xx.xx (dot) format, but only in xx,xx (comma). I think this is because I live in Italy and my system and region settings are according (we use commas for doubles). How can I change the locale of my JVM to make it accept xx.xx format doubles?