zunior
zunior

Reputation: 861

java.nio.charset.UnmappableCharacterException: Input length = 1

Full error message:

java.nio.charset.UnmappableCharacterException: Input length = 1
at java.nio.charset.CoderResult.throwException(CoderResult.java:261)
at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:266)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:106)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:116)
at java.io.Writer.write(Writer.java:140)
at scala.xml.XML$.write(XML.scala:108)
at scala.xml.XML$$anonfun$save$2.apply$mcV$sp(XML.scala:91)
at scala.xml.XML$$anonfun$save$2.apply(XML.scala:91)
at scala.xml.XML$$anonfun$save$2.apply(XML.scala:91)
at scala.util.control.Exception$Catch.apply(Exception.scala:102)
at scala.xml.XML$.save(XML.scala:90)
at agent.Main$$anonfun$2.apply$mcV$sp(Main.scala:32)

My code at Main Line 32:

scala.xml.XML.save(nameBuilder(),file)

What do I need to change here? Are there unprintable characters in the file?

Thanks in advance

Upvotes: 4

Views: 10248

Answers (1)

Andreas Neumann
Andreas Neumann

Reputation: 10904

You have to provide the correct encoding. The save method takes that as a parameter. see http://www.scala-lang.org/api/2.10.4/index.html#scala.xml.XML%24

scala.xml.XML.save(nameBuilder(),file, "UTF-8")

Upvotes: 7

Related Questions