just a quick question.
I wonder how many characters count for \n (new line ) in JAVA?
Because I need to fit 160 chars in one String,etc.
So.. How many chars should I consider for \n when appending to my StringBuffer?
Thanks
'\n'
itself is one character when represented internally in Java, but when interfacing with external systems it can be represented by anywhere between 1 and 8 bytes. Some systems and protocols represent a newline with \r\n
, which is 2 characters. And the encoding matters as well, since it can cause each character to use 1, 2, or 4 bytes.
Without more information on what system or protocol the characters are going to be sent on it is not possible to give a completely accurate answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With