Get binary size of particular String JAVA
java, string
Solution
get bytes, mutiply by 8...
"xxx".getBytes().length * 8;
Edit: merging with the answer of Jon Skeet, it's could be also important to specify the encoding, otherwise this will return the size using the system's default encoding, and that's not necessarily what you want to know. To know the size using a certain encoding, use:
"xxx".getBytes(encoding).length * 8;
encoding being "UTF-8", "ASCII", or whatever you want to use.
Problem
How to get a binary size of a String(for example String s = "Ababa") in BITS(not bytes).