public static < T extends TBase < ? , ? > > T fromBytes ( byte [ ] data , Class < T > clazz ) throws TException { if ( data == null ) { return null ; } ByteArrayInputStream bais = new ByteArrayInputStream ( data ) ; try { TTransport transport = new TIOStreamTransport ( bais , null ) ; TProtocol iProtocol = protocolFactory . getProtocol ( transport ) ; T record = clazz . newInstance ( ) ; record . read ( iProtocol ) ; // bais.close(); return record ; } catch ( InstantiationException | IllegalAccessException e ) { throw new TException ( e ) ; } }
Deserializes a thrift object from byte array .