Convert the data as string as below and check the result. You should see the value as "AAAcd".
Short Answer:-
String binaryDataAsString = new String (item.getBinary("binary_col"));
System.out.println("Binary data as string ====================>" + binaryDataAsString);
Just for your reference:-
public Boolean getAutoTableDataWithoutMapper(String autoId) {
DynamoDB dynamoDB = new DynamoDB(dynamoDBClient);
Table table = dynamoDB.getTable("autotable");
ItemCollection<QueryOutcome> items = null;
QuerySpec querySpec = new QuerySpec();
querySpec.withKeyConditionExpression("autoID = :val1").withValueMap(new ValueMap().withString(":val1", autoId));
items = table.query(querySpec);
Iterator<Item> iterator = items.iterator();
while (iterator.hasNext()) {
Item itemData = iterator.next();
System.out.println("Json data ====================>" + itemData.toJSONPretty());
System.out.println("Binary data ====================>" + itemData.getBinary("binaryData"));
String binaryDataAsString = new String(itemData.getBinary("binaryData"));
System.out.println("Binary data as string ====================>" + binaryDataAsString);
}
return true;
}
Output:-
Please look at the "Binary data as string". The string is displayed correctly.
If you look at Json data, the value is displayed as mentioned in your question (i.e. "QUFBY2Q=").
Json data ====================>{
"binaryData" : "QUFBY2Q=",
"autoID" : "fge",
"alexandriaID" : "122"
}
Binary data ====================>[B@3954d008
Binary data as string ====================>AAAcd