Read float numbers from file

前端 未结 2 388
醉梦人生
醉梦人生 2021-01-26 06:36

How to read float numbers from file?

  0.00000E+00  2.12863E-01
  1.00000E-02  2.16248E-01
  2.00000E-02  2.19634E-01

in the file 2 spaces befo

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-26 07:08

    So, I understand my mistake. I need to use

    s.useLocale(Locale.US);
    

    because that Scanner interpets "." as decimal separator, in my locale (default) it is ",". Also note that both 1.1 and 3 (integer) are recognized by nextDouble

    //according to this link

提交回复
热议问题