Scala Converting multiline string to BigInt

♀尐吖头ヾ 提交于 2019-12-01 18:40:26

Probably you're on Windows, where the EOL is \r\n.

You've got to strip that, too.

Here, I rebooted into Windows to demo...

apm@halyard ~/tmp
$ vi bigbomb.scala

apm@halyard ~/tmp
$ skalac bigbomb.scala ; skala bigbomb.Test
"ava.lang.NumberFormatException: For input string: "35740250
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)

Note that in cygwin, I have to :se fileformat=dos in vi to use the \r\n line endings.

Here is an example where the unacknowledged impedance mismatch between the source EOL and the runtime EOL bugged me:

some dumb code

You want to use s.lines.mkString to strip it out.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!