本帖最后由 beichui 于 2013-06-06 15:17:41 编辑

解决方案 »

  1.   

    write(int)方法不是会删除高3位字节的数据么这是啥意思?
      

  2.   

        /**
         * 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个字节会无视掉。
      

  3.   

    我是这样认为,上面的write方法只不过是一个抽象方法,具体情况应该依据他的重写的方法吧。就像OutputStream类中的  public void write(byte b[], int off, int len) throws IOException ,他不是也没实现将写入outputStream流的字节的前三位忽视掉吗?个人见解!!
      

  4.   

    OutputStream 只是抽象基类,单字节写入的原子操作具体实现是ByteArrayOutputStream 和 FileOutputStream 这2个装饰模式的核心类实现的。