【发布时间】:2011-10-30 22:21:06
【问题描述】:
我有这个发送字符串或整数,但如果我想发送一个字符串数组我应该使用什么?
// A string ("Hello, World").
out.write("Hello, World".getBytes());
// An integer (123).
out.write(ByteBuffer.allocate(4).putInt(123).array());
提前致谢
【问题讨论】:
-
我强烈建议使用
.getBytes( "UTF-8" )为您的字符串获取安全的字节编码。
标签: java sockets objectoutputstream