title: Converting cassandra blob type to string
body: <p>I have an old column family which has a column named "value" which was defined as a blob data type. This column usually holds two numbers separated with an underscore, like "421_2". </p>
  
  <p>When im using the python datastax driver and execute the query, the results return with that field parsed as a string:</p>
  
  <pre><code>In [21]: session.execute(q)
  Out[21]: 
  [Row(column1=4776015, value='145_0'),
   Row(column1=4891778, value='114_0'),
   Row(column1=4891780, value='195_0'),
   Row(column1=4893662, value='105_0'),
   Row(column1=4893664, value='115_0'),
   Row(column1=4898493, value='168_0'),
   Row(column1=4945162, value='148_0'),
   Row(column1=4945163, value='131_0'),
   Row(column1=4945168, value='125_0'),
   Row(column1=4945169, value='211_0'),
   Row(column1=4998426, value='463_0')]
  </code></pre>
  
  <p>When I use the java driver I get a com.datastax.driver.core.Row object back. When I try to read the value field by, for example, <code>row.getString("value")</code> I get the expected <code>InvalidTypeException: Column value is of type blob</code>. Seems like the only way to read the field is via <code>row.getBytes("value")</code> and then I get back an <code>java.nio.HeapByteBuffer</code> object.</p>
  
  <p>Problem is, I cant seem to convert this object to string in an easy fashion. Googling yielded two answers from 2012 that suggest the following:</p>
  
  <pre><code>String string_value = new String(result.getBytes("value"), "UTF-8");
  </code></pre>
  
  <p>But such a String constructor doesn't seems to exist anymore.
  So, my questions are:</p>
  
  <ol>
  <li>How do I convert HeapByteBuffer into string?</li>
  <li>How come the python driver converted the blob easily and the java one did not?</li>
  </ol>
  
  <p>Side Note:
  I could debug the python driver, but currently that seems too much work for something that should be trivial. (and the fact that no one asked about it suggests Im missing something simple here..)</p>