Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert org.apache.avro.util.Utf8 to java.lang.String [closed]

Tags:

java

avro

I write a sample with avro library. It generate java class source code User from schema record User.

I want to encode User to byte[], and decode byte[] to User.

When decoding, I've got error message:

java.lang.ClassCastException: org.apache.avro.util.Utf8 cannot be cast to java.lang.String

How to convert org.apache.avro.util.Utf8 to java String ?

like image 993
linrongbin Avatar asked Sep 08 '19 06:09

linrongbin


1 Answers

You can use its method toString()

toString in interface CharSequence

like image 174
user7294900 Avatar answered Nov 12 '22 19:11

user7294900