Why do I get a MalformedInputException from this code?

前端 未结 2 1229
你的背包
你的背包 2020-12-15 17:58

I\'m a newbie in Scala, and I wanted to write some sourcecodes from myself for me to get better. I\'ve written a simple object (with a main entry) in order to simulate a \"g

2条回答
  •  攒了一身酷
    2020-12-15 18:33

    You can handle this character encoding exception by adding below snippet in your code

    import scala.io.Codec
    import java.nio.charset.CodingErrorAction
    
    
    implicit val codec = Codec("UTF-8")
    codec.onMalformedInput(CodingErrorAction.REPLACE)
    codec.onUnmappableCharacter(CodingErrorAction.REPLACE)
    

提交回复
热议问题