当前位置: 技术问答>java相关
请问怎么通过Socket发送一个int数值?急,谢谢!!
来源: 互联网 发布时间:2015-10-26
本文导语: 我用OutputStream.write(intData),结果只发送了第一个字节的数据,用OutputStream.write_long(intData),编译错误。怎样才能发出去啊?谢谢 | byte buffer[] = new byte[BUF_SIZE]; FileInputStream streamInput = new FileInpu...
我用OutputStream.write(intData),结果只发送了第一个字节的数据,用OutputStream.write_long(intData),编译错误。怎样才能发出去啊?谢谢
|
byte buffer[] = new byte[BUF_SIZE];
FileInputStream streamInput = new FileInputStream( sFileName );
DataOutputStream outStream = new DataOutputStream( sockSend.getOutputStream() );
outStream.writeInt( nFileSize );
FileInputStream streamInput = new FileInputStream( sFileName );
DataOutputStream outStream = new DataOutputStream( sockSend.getOutputStream() );
outStream.writeInt( nFileSize );
|
用OutputStream.writeInt(intData);