public final long fromBitString2Long ( String str ) { if ( str . length ( ) > 64 ) throw new UnsupportedOperationException ( "Strings needs to fit into a 'long' but length was " + str . length ( ) ) ; long res = 0 ; int strLen = str . length ( ) ; for ( int charIndex = 0 ; charIndex < strLen ; charIndex ++ ) { res <<= 1 ; if ( str . charAt ( charIndex ) != ' ' ) res |= 1 ; } res <<= ( 64 - strLen ) ; return res ; }
The only purpose of this method is to test reverse . toBitString is the reverse and both are independent of the endianness .