Get binary size of particular String JAVA -
how binary size of string(for example string s = "ababa") in bits(not bytes).
get bytes, mutiply 8...
"xxx".getbytes().length * 8;
edit: merging answer of jon skeet, it's important specify encoding, otherwise return size using system's default encoding, , that's not want know. know size using encoding, use:
"xxx".getbytes(encoding).length * 8;
encoding being "utf-8", "ascii", or whatever want use.
Comments
Post a Comment