Example #1
0
def read():
    '''
    test read object from bianry file
    '''
    bin_file = open("E:/workspace-sts-3.6.1.RELEASE/JavaDemo/1.dat", "rb", 1024)
    bean_pair = Pair()
    trans = TTransport.TFileObjectTransport(bin_file)
    ibp = TBinaryProtocol.TBinaryProtocol(trans)
    bean_pair.read(ibp)
    print bean_pair.key
Example #2
0
def write():
    '''
    test write object to bianry file
    '''
    bin_file = open("E:/workspace-sts-3.6.1.RELEASE/JavaDemo/1.dat", "w+b", 1024)
    bean_pair = Pair()
    bean_pair.key = "username"
    bean_pair.value = "rookiefly" 
    trans = TTransport.TFileObjectTransport(bin_file)
    ibp = TBinaryProtocol.TBinaryProtocol(trans)
    bean_pair.write(ibp)