DataInputStream and UTF-8

前端 未结 1 1388
情深已故
情深已故 2020-12-21 08:17

I\'m kind of a new programmer, and I\'m having a couple of problems with the code I\'m handling.

Basically what the code does is receive a form from another JSP, rea

相关标签:
1条回答
  • 2020-12-21 08:37

    The problem is not in the inputstreams since they doesn't handle characters, but only bytes. Your problem is at the point you convert those bytes to characters. In this particular case, you need to specify the proper encoding in the String constructor.

    String notes = new String(dataBytes, "UTF-8");
    

    See also:

    • Unicode - How to get characters right?

    By the way, the DataInputStream has no additional value in the particular code snippet. You can just keep it InputStream.

    0 讨论(0)
提交回复
热议问题