{"id":61472,"date":"2022-05-16T02:34:26","date_gmt":"2022-05-16T02:34:26","guid":{"rendered":"https:\/\/assignmenttutors.net\/blog\/bitoutputstream-implement-a-class-named-bitoutputstream-as-shownin\/"},"modified":"2022-05-16T02:34:26","modified_gmt":"2022-05-16T02:34:26","slug":"bitoutputstream-implement-a-class-named-bitoutputstream-as-shownin","status":"publish","type":"post","link":"https:\/\/assignmenttutors.net\/blog\/bitoutputstream-implement-a-class-named-bitoutputstream-as-shownin\/","title":{"rendered":"(bitoutputstream) implement a class named bitoutputstream, as shownin"},"content":{"rendered":"<div>\n<p>(BitOutputStream) Implement a class named BitOutputStream, as shown<\/p>\n<p>in Figure 19.20, for writing bits to an output stream. The writeBit(char<\/p>\n<p>bit) method stores the bit in a byte variable. When you create a<\/p>\n<p>BitOutputStream, the byte is empty. After invoking writeBit(&#8216;1&#8217;), the<\/p>\n<p>byte becomes 00000001. After invoking writeBit(&#8220;0101&#8221;), the byte<\/p>\n<p>becomes 00010101. The first three bits are not filled yet. When a byte is full, it<\/p>\n<p>is sent to the output stream. Now the byte is reset to empty. You must close the<\/p>\n<p>stream by invoking the close() method. If the byte is not empty and not full,<\/p>\n<p>the close() method first fills the zeros to make a full 8 bits in the byte, and<\/p>\n<p>then output the byte and close the stream. For a hint, see Exercise 4.46. Write a<\/p>\n<p>test program that sends the bits 010000100100001001101 to the file named<\/p>\n<p>Exercise19_17.dat.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>(BitOutputStream) Implement a class named BitOutputStream, as shown in Figure 19.20, for writing bits to an output stream. The writeBit(char bit) method stores the bit in a byte variable. When you create a BitOutputStream, the byte is empty. After invoking writeBit(&#8216;1&#8217;), the byte becomes 00000001. After invoking writeBit(&#8220;0101&#8221;), the byte becomes 00010101. The first three [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-61472","post","type-post","status-publish","format-standard","hentry","category-education"],"_links":{"self":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/61472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/comments?post=61472"}],"version-history":[{"count":0,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/61472\/revisions"}],"wp:attachment":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/media?parent=61472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/categories?post=61472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/tags?post=61472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}