位运算符的问题
请各位同仁帮我解释一下 ,下面的代码
public void sendString(PrintStream outstream, String string) {
// TODO Auto-generated method stub
try {
outstream.println(string.length());
int len = string.length() * 2;
byte buf[] = new byte[len];
for (int i = 0; i < string.length(); i++) {
buf[i * 2] = (byte) (string.charAt(i) >> 8);
buf[i * 2 + 1] = (byte) string.charAt(i);
}
outstream.write(buf, 0, len);//将 len 字节从指定的初始偏移量为 0 的字节数组写入此流。
outstream.flush();
} catch (Exception e) {
offline = true;
System.out.println(" sendString() error:" + e);
}
}