Get a bit string from the input stream.  The bit string need
not be byte-aligned.
487268
public BitArray getUnalignedBitString() throws IOException {
        if (buffer.read() != DerValue.tag_BitString)
            throw new IOException("DER input not a bit string");

        int length = getLength(buffer) - 1;

        /*
         * First byte = number of excess bits in the last octet of the
         * representation.
         */
        int validBits = length*8 - buffer.read();

        byte[] repn = new byte[length];

        if ((length != 0) && (buffer.read(repn) != length))
            throw new IOException("short read of DER bit string");
        return new BitArray(validBits, repn);
    }
430329
private static String getStringFromInputStream(InputStream is)
    {
        BufferedReader br = null;
        StringBuilder sb = new StringBuilder();

        String line;
        try
        {
            br = new BufferedReader(new InputStreamReader(is));
            while((line = br.readLine()) != null)
            {
                sb.append(line);
            }

        }
        catch(IOException e)
        {
            logger.severe("Unable to get string from stream: "+e.getClass().getName()+": "+e.getMessage());
        }
        finally
        {
            try
            {
                if(br != null)
                    br.close();
            }
            catch(IOException e)
            {
            }
        }

        return sb.toString();
    }
1216760
def _get_raw(source, bitarray):
        '''  '''
        offset = int(source['offset'])
        size = int(source['size'])
        return int(''.join(['1' if digit else '0' for digit in bitarray[offset:offset + size]]), 2)
881547
public byte[] getBitString(boolean tagImplicit) throws IOException {
        if (!tagImplicit) {
            if (tag != tag_BitString)
                throw new IOException("DerValue.getBitString, not a bit string "
                                       + tag);
            }
        return buffer.getBitString();
    }
178500
public static String get(byte[] bytes, int from, int to) {
        final StringBuilder bld = new StringBuilder();
        for (int i = from; i < to; i++) {
            bld.append(Hex.get(bytes[i]));
        }
        return bld.toString();
    }
812260
public String getString(ByteBuffer bytes)
    {
        TypeSerializer<T> serializer = getSerializer();
        serializer.validate(bytes);

        return serializer.toString(serializer.deserialize(bytes));
    }
85827
def from_binary_string(self, stream):
        """"""
        command, code, identifier = struct.unpack(self.FORMAT, stream)

        if command != self.COMMAND:
            raise ErrorResponseInvalidCommandError()

        if code not in self.CODES:
            raise ErrorResponseInvalidCodeError()

        self.code = code
        self.name = self.CODES[code]
        self.identifier = identifier
407280
def read_bit(self):
        
        # Perform a faster check on underflow
        if self._pos >= self._end_pos:
            raise self.BufferUnderflow()
        result = ord(self._input[self._pos]) & 1
        self._pos += 1
        return result
1104381
public byte getByte(long pos) {
    checkOffsetAndCount(size, pos, 1);
    for (Segment s = head; true; s = s.next) {
      int segmentByteCount = s.limit - s.pos;
      if (pos < segmentByteCount) return s.data[s.pos + (int) pos];
      pos -= segmentByteCount;
    }
  }
653214
static public byte[] getBytes(String input) {

        if (null != input) {
            int length = input.length();
            byte[] output = new byte[length];
            for (int i = 0; i < length; i++) {
                output[i] = (byte) input.charAt(i);
            }
            return output;
        }
        return null;
    }
827201
def __BitList_to_String(self, data):
		""""""
		result = []
		pos = 0
		c = 0
		while pos < len(data):
			c += data[pos] << (7 - (pos % 8))
			if (pos % 8) == 7:
				result.append(c)
				c = 0
			pos += 1

		if _pythonMajorVersion < 3:
			return ''.join([ chr(c) for c in result ])
		else:
			return bytes(result)
338063
public static final long fromBitSet(final BitSet bits) {
    long value = 0L;
    for (int i = 0; i < bits.size(); i++) {
      value += bits.get(i) ? (1L << i) : 0L;
    }
    return value;
  }
975265
public static String byteArrayToBitString(byte[] bytes, int bitCount) {

        char[] s = new char[bitCount];

        for (int j = 0; j < bitCount; j++) {
            byte b = bytes[j / 8];

            s[j] = BitMap.isSet(b, j % 8) ? '1'
                                          : '0';
        }

        return new String(s);
    }
773232
def _readuint(self, length, start):
        """"""
        if not length:
            raise InterpretError("Cannot interpret a zero length bitstring "
                                           "as an integer.")
        offset = self._offset
        startbyte = (start + offset) // 8
        endbyte = (start + offset + length - 1) // 8

        b = binascii.hexlify(bytes(self._datastore.getbyteslice(startbyte, endbyte + 1)))
        assert b
        i = int(b, 16)
        final_bits = 8 - ((start + offset + length) % 8)
        if final_bits != 8:
            i >>= final_bits
        i &= (1 << length) - 1
        return i
1263949
private static String getStringFromInputStream(InputStream inputStream, boolean trim) throws IOException {
    BufferedReader bufferedReader = null;
    StringBuilder stringBuilder = new StringBuilder();
    try {
      bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
      String line;
      while ((line = bufferedReader.readLine()) != null) {
        if (trim) {
          stringBuilder.append(line.trim());
        }
        else {
          stringBuilder.append(line).append("\n");
        }
      }
    }
    finally {
      closeSilently(bufferedReader);
    }

    return stringBuilder.toString();
  }
1288982
@Override
	public Object extractValueFromBytes(int offset, byte[] bytes, boolean required) {
		// we don't need to extract the value if all we are doing is matching
		if (!required) {
			return EMPTY;
		}
		if (offset >= bytes.length) {
			return null;
		}
		// length is from the first byte of the string
		int len = (bytes[offset] & 0xFF);
		int left = bytes.length - offset - 1;
		if (len > left) {
			len = left;
		}
		char[] chars = new char[len];
		for (int i = 0; i < chars.length; i++) {
			chars[i] = (char) (bytes[offset + 1 + i] & 0xFF);
		}
		/*
		 * NOTE: we need to make a new string because it might be returned if we don't match below.
		 */
		return new String(chars);
	}
793604
public static InputStream getStringInputStream(String string)
    {
        InputStream is = null;
        try   {
            ByteArrayOutputStream ba = new ByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(ba);
            os.writeUTF(string);
            os.flush();
            is = new ByteArrayInputStream(ba.toByteArray());
        } catch (IOException ex)    {
            ex.printStackTrace();
        }
        return is;
    }