this is a small program using Java Scanner which reads a file of double values and sum it up.
I was verifying using certain locale’s, and for German\Germany the value is zero.
Here is the code snippet,
s= new Scanner((Readable) new BufferedReader(new FileReader("ScanNum")));
s.useLocale(Locale.GERMAN);
System.out.println(s.locale());
while(s.hasNextDouble())
{
sum+=s.nextDouble();
}
and the file which holds double values,
8.5
32,767
3.14159
1,000,000.1
other locales the value returned is1032778.74159.
Pls advise,
Thanks!!
8.5 isn’t a valid
doublevalue in the German locale, basically. German (and many other European locales) uses,as a decimal separator, and.as a thousands separator. So in German, your text file would have to look like this: