Javaを使用してデータをバイナリファイルに保存したいと思います。たとえば、番号は 101 で、私のプログラムでは出力ファイルのサイズは 4 バイトです。出力ファイルに数値を 3 ビット (101) だけで保存するにはどうすればよいですか? 私のプログラムは次のようになります。
public static void main(String args[]) throws FileNotFoundException, IOException {
    int i = 101;
    DataOutputStream os = new DataOutputStream(new FileOutputStream("file"));
    os.writeInt(i);
    os.close();
}
私はそのようなものを見つけました: http://www.developer.nokia.com/Community/Wiki/Bit_Input/Output_Stream_utility_classes_for_effective_data_transfer