You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by 熊峰 <xi...@gmail.com> on 2012/07/17 11:03:16 UTC

About Thrift binary data type

Hi guys!I have a problem with Thrift binary data type. Both server side and
client side of my application use Java. I defined a service in my IDL file
as follow:
service ImageService {
binary getImage();
}
My implementation as follow:
public ByteBuffer getImage() throws TException {
ByteBuffer buf_ = null;
try {
FileInputStream fin = new FileInputStream("E:\\2.jpg");
int size = fin.available();
buf_ = ByteBuffer.allocate(size);
FileChannel fcin = fin.getChannel();
int count = fcin.read(buf_);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
 return buf_;
}
But when i call getImage() method in my client and got the return value as
ByteBuffer like this:
ByteBuffer _buf = client.getImage();
I find that the _buf object stored nothing in it.  I really feel confused.
Who can help? Many Thanks!!!