Dear Wiki user, You have subscribed to a wiki page or wiki category on "Thrift Wiki" for change notification.
The following page has been changed by StuartSierra: http://wiki.apache.org/thrift/ThriftUsageJava The comment on the change is: Created page with some examples New page: Assuming you're using the definitions in "tutorial.thrift": == Importing the Classes == You may not need all of these. {{{ import com.facebook.thrift.TBase; import com.facebook.thrift.TException; import com.facebook.thrift.TSerializer; import com.facebook.thrift.protocol.TBinaryProtocol; import com.facebook.thrift.protocol.TProtocol; import com.facebook.thrift.protocol.TProtocolFactory; import com.facebook.thrift.protocol.TSimpleJSONProtocol; import com.facebook.thrift.transport.TIOStreamTransport; import com.facebook.thrift.transport.TTransport; import tutorial.Work; import tutorial.Operation; import tutorial.Constants; }}} == Creating Objects, Using Constants == {{{ Work work = new Work(); work.num1 = 7; work.num2 = 9; work.op = Operation.ADD; }}} == Serializing to a Byte Array == {{{ TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory()); byte[] bytes = serializer.serialize(work); }}}
