some example to send big file from server to client?
tantom
tantom2000 at gmail.com
Thu May 21 13:49:37 EDT 2009
hi
thanks,it's ok. below it's my test code,i post it hope to help next who
encount same with me:)
File f = new File("g:\\test.msi");
String params = "GetFile|test.msi";
byte[] bsParams = params.getBytes("UTF-8");
ChannelBuffer response = ChannelBuffers.buffer(8 +
bsParams.length);
response.writeBytes(CTypeConvert.int2byte(bsParams.length));
response.writeBytes(CTypeConvert.int2byte((int)
f.length()));
response.writeBytes(bsParams);
//write the header info first
channel.write(response);
FileInputStream fis = new FileInputStream(f);
int len;
byte[] bs = new byte[1024];
while ((len = fis.read(bs)) > 0) {
ChannelBuffer buffer = ChannelBuffers.buffer(len);
buffer.writeBytes(bs);
channel.write(buffer);
}
fis.close();
--
View this message in context: http://n2.nabble.com/some-example-to-send-big-file-from-server-to-client--tp2952981p2953300.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list