Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Read/write values into java memory  RSS feed

 
Hari Dhanakoti
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, far I have tried to write the byte values wit the encoding format "ISO-8859-1" using ByteArrayInputStream(b),Charset.forName("ISO-8859-1");

How the values of the string be written to the java memory?

When I try to read the value in a stream how they should be read with the same encoding format (ISO-8859-1)?
 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Strings are always stored in Java memory as a collection of two byte Unicode characters. You don't have any control over that. How you read or write Strings with streams depends what's on the other end of that stream. You could certainly read or write the Unicode characters without any conversion, but if you are talking to another program that doesn't understand Unicode, you will have ... a failure to communicate.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!