(BitOutputStream) Implement a class named BitOutputStream, as shown in Figure 17.22, 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(‘1’), the byte becomes 00000001. After invoking writeBit (“0101”), the byte becomes 00010101. The first three bits are not filled yet. When a byte is full, it is sent to the output stream. Now the byte is reset to empty. You must close the stream by invoking the close() method. If the byte is neither empty nor full, the close() method first fills the zeros to make a full 8 bits in the byte and then outputs the byte and closes the stream. For a hint, see Programming Exercise 5.44. Write a test program that sends the bits 010000100100001001101 to the file named Exercise17_17.dat.
FIGURE 17.22 BitOutputStream outputs a stream of bits to a file.
Want to see the full answer?
Check out a sample textbook solutionChapter 17 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Modern Database Management (12th Edition)
Concepts of Programming Languages (11th Edition)
Starting Out with C++: Early Objects
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Introduction To Programming Using Visual Basic (11th Edition)
- MODIFY THE CODE BELOW try..arrow_forwardwrite pseudo code following this :arrow_forwardTrace the following Code and then print the output. msg db 'hello world$' newline db 10,13,'$' buffer db 10 dup mov ah,9 mov dx,offset msg int 21h ;new line mov ah,9 mov dx, offset newline int 21h ;enter a string from the keyboard lea dx,buffer mov ah,0ah int 21h ;new line mov ah,9 mov dx,offset newline int 21h ;adding the $ symbol at the end of the string mov bx,0 mov bl,buffer[1] mov buffer[bx+2],'$' mov ah,9 mov dx,offset buffer+2 int 21harrow_forward
- If you're writing output to a binary file, what classes do you use to do this? What classes do you use to read data from a binary file and how do you do it?arrow_forwardWhat is the importance of including '0' in saving the data to the RAM?arrow_forwardWhich Direction flag setting causes index registers to move backward through memorywhen executing string primitives?arrow_forward
- What is the effect of Examining data "print 0x100"?arrow_forwardIf we manipulate can the _____, we can manipulate the memory.arrow_forwardThe code below is written in C. In C, for each integer variable 4 Byte, for each char variable 1 Byte, and for each double variable 8 Byte are allocated from the memory. After the execution of the code below, how many bytes are leaked? int main (){ int *a; a = (int*) malloc (60*sizeof(int)); a[0] = 60; a = (double*) malloc (a[0]*sizeof(double)); char *d,*c = (char*) malloc (10*sizeof(char)); double b = 5; free(a); free(d); return 0; }arrow_forward
- Using the byte-stuffing approach described above, the data stream contains the following data fragment:An A, B, C, D, ESC, and a FAfter filling, what is the final result??arrow_forwardFor the format string in a printf function, e.g., "Hello!" in the printf("Hello!"), the compiler (say gcc) will allocate space for "Hello!" in the ".data" section. Question 4 options: True False The "test" object file is a "Shared Object File" rather than an executable. test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=8ec64a3b2a1f26d36a957f47c6e857000d202fdd, for GNU/Linux 3.2.0, not stripped Question 5 options: True Falsearrow_forward1) The R programming code shown below will produce the following output: Output: one two 1 1 TRUE 2 2 TRUE 3 3 FALSE 4 4 FALSE Code:> x <- data.frame(one = 1:4, two = c(T, T, F, F)) > x True False 2) readlines is used for working on data. True False 3) The function as.matr() converts a data frame into a matrix. True False 4) The R programming statement data <- read.table(“egcc.txt”) read file “egcc.txt.” True False 5) The following R programming code will read 100 rows: tabAll <- read.table(“datatable.txt”, colClasses = classes) True False 6) Read.csv is used to read in tabular data. True False 7) The R programming load function is used for reading in saved workspaces. True False 8) The copy function accepts any number of arguments and concatenates them into character strings. True False 9) The read.data() function is one of the most commonly used functions for reading data True False 10) To read in data from a saved workspace, use the load command. True…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education