关于FileOutputStream中写一个字节的有关问题

关于FileOutputStream中写一个字节的问题?
FileOutputStream有一个方法: public native void write(int b) throws IOException;

这个方法的参数是int b (在Java中是四个字节),并且这个参数b就是要写入的字节。
但是这个方法的说明文档中说:
Writes the specified byte to this file output stream. Implements the <code>write</code> method of <code>OutputStream</code>.
也就是说这个方法是每次写入一个指定的字节.

我想问,是不是将int的最后一个字节(最低字节)写入文件中,前三个字节都不要了。

我有一个可证明这种想法的例子,就是在DataOutputStream中有一个writeInt(int v)的源代码:
Java code
    public final void writeInt(int v) throws IOException {
        out.write((v >>> 24) & 0xFF);
        out.write((v >>> 16) & 0xFF);
        out.write((v >>>  8) & 0xFF);
        out.write((v >>>  0) & 0xFF);
        incCount(4);
    }

我们可以看到,通过>>>位操作,将整形v中四个字节的每一个字节都移动到最后一个字节(最低字节),并且write出了。是不是可以说明需要写入的就是最后一个字节(最低字节)。


------解决方案--------------------
对,就是(byte)i
------解决方案--------------------
如果说只输出最后一字节,那么下面是不是应该输出aa,可结果只输出一个a,不明白啊,给解释一下吧
FileOutputStream fo = new FileOutputStream("D:/a.txt");
fo.write(97); 
fo.write(97+1<<8);
------解决方案--------------------
YES,前三字节没了,就LZ你的,运行一下就行了
Java code

        FileOutputStream out = new FileOutputStream("D:/a.txt");
        int v = 0x61626364;//0x61为'a' ASCII
        out.write(v >>> 24);
        out.write(v >>> 16);
        out.write(v >>> 8);
        out.write(v);//v
        System.out.println("" + v + "," + (char) (v & 0xff));
        out.close();
/*run:
1633837924,d
成功生成(总时间:2 秒)
*/

/*D:/a.txt中
abcd
*/

------解决方案--------------------
探讨
FileOutputStream有一个方法: public native void write(int b) throws IOException;

这个方法的参数是int b (在Java中是四个字节),并且这个参数b就是要写入的字节。
但是这个方法的说明文档中说:
Writes the specified byte to this file output stream. Implements the <code>write </code> method of <code>OutputStream </code>.
也就是说这个方法是每次写入一个指定的字节.

我想问,是不是将int的最后一个字节(最低字节)写入文件中,前三个字节都不要了。

我有一个可证明这种想法的例子,就是在DataOutputStream中有一个writeInt(int v)的源代码:
Java codepublicfinalvoid writeInt(int v)throws IOException {
out.write((v>>>24)&0xFF);
out.write((v>>>16)&0xFF);
out.write((v>>>8)&0xFF);
out.write((v>>>0)&0xFF);
incCount(4);
}
我们可以看到,通过>>>位操作,将整形v中四个字节的每一个字节都移动到最后一个字节(最低字节),并且write出了。是不是可以说明需要写入的就是最后一个字节(最低字节)。


------解决方案--------------------
ObjectOutputStream 你应该用这个方法写非byte类型