/** * Writes the specified byte to this output stream. The general * contract for <code>write</code> is that one byte is written * to the output stream. The byte to be written is the eight * low-order bits of the argument <code>b</code>. The 24 * high-order bits of <code>b</code> are ignored. * <p> * Subclasses of <code>OutputStream</code> must provide an * implementation for this method. * * @param b the <code>byte</code>. * @exception IOException if an I/O error occurs. In particular, * an <code>IOException</code> may be thrown if the * output stream has been closed. */ JAVA API已经说明了,这个方法本身就会无视前三个字节,int类型是4字节的,字节流写入的原子操作是单字节的,所以JAVA 规定前面3个字节会无视掉。
我是这样认为,上面的write方法只不过是一个抽象方法,具体情况应该依据他的重写的方法吧。就像OutputStream类中的 public void write(byte b[], int off, int len) throws IOException ,他不是也没实现将写入outputStream流的字节的前三位忽视掉吗?个人见解!!
* Writes the specified byte to this output stream. The general
* contract for <code>write</code> is that one byte is written
* to the output stream. The byte to be written is the eight
* low-order bits of the argument <code>b</code>. The 24
* high-order bits of <code>b</code> are ignored.
* <p>
* Subclasses of <code>OutputStream</code> must provide an
* implementation for this method.
*
* @param b the <code>byte</code>.
* @exception IOException if an I/O error occurs. In particular,
* an <code>IOException</code> may be thrown if the
* output stream has been closed.
*/
JAVA API已经说明了,这个方法本身就会无视前三个字节,int类型是4字节的,字节流写入的原子操作是单字节的,所以JAVA 规定前面3个字节会无视掉。