How to skip invalid characters in stream in Java/Scala?

前端 未结 4 1642
面向向阳花
面向向阳花 2021-02-02 12:53

For example I have following code

Source.fromFile(new File( path), \"UTF-8\").getLines()

and it throws exception

Exception in         


        
4条回答
  •  情歌与酒
    2021-02-02 13:12

    I had a similar issue, and one of Scala's built-in codecs did the trick for me:

    Source.fromFile(new File(path))(Codec.ISO8859).getLines()
    

提交回复
热议问题