Home Features Docs Blog Support GitHub

Error when writing string data to file

(Eugene) #1

I’ve been having a really odd exception in the Java layer on iOS emulated by MOE runtime. Here is a stack trace below. I wonder anyone experienced anything similar and if there is any work around for this? Seem to be related to some buffering of encoded String data, but it doesn’t look related to any specific encoding in the content and just the size of the data written

The Write instance is created like this:

Writer w = new OutputStreamWriter(new FileOutputStream(fileName), "utf-8");

@kisg any suggestions?

Fatal Exception: java.lang.IllegalArgumentException
java.lang.IllegalArgumentException: Bad position (limit 8192): 8196
  at java.nio.Buffer.positionImpl(Buffer.java:351)
  at java.nio.Buffer.position(Buffer.java:345)
  at java.nio.charset.CharsetEncoderICU.setPosition(CharsetEncoderICU.java:234)
  at java.nio.charset.CharsetEncoderICU.encodeLoop(CharsetEncoderICU.java:183)
  at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:374)
  at java.io.OutputStreamWriter.convert(OutputStreamWriter.java:181)
  at java.io.OutputStreamWriter.write(OutputStreamWriter.java:327)
  at java.io.Writer.write(Writer.java:141)