Exam 13: File Input and Output

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

____ applications require that a record be accessed immediately while a client is waiting.

(Multiple Choice)
4.9/5
(82)

You can direct System.err to a new location, such as a disk file or printer, but you cannot direct System.out to a new location.

(True/False)
4.9/5
(78)

A file channel is ____, meaning you can search for a specific file location and operations can start at any specified position.

(Multiple Choice)
4.8/5
(83)

import java.nio.file.*; import java.io.*; import java.nio.channels.FileChannel; import java.nio.ByteBuffer; import static java.nio.file.StandardOpenOption.*; public class CreateOneRandomAccessRecord {     public static void main(String[] args)     {        Path file =          Paths.get("C:\\Java\\Chapter.13\\RandomEmployees.txt");        String s = "002,Newmann,12.25" +          System.getProperty("line.separator");        --------- Code here -------------        byte[] data = s.getBytes();        ByteBuffer buffer = ByteBuffer.wrap(data);        FileChannel fc = null;        try        {           fc = (FileChannel)Files.newByteChannel(file, READ, WRITE);           fc.position(2 * RECSIZE);           fc.write(buffer);           fc.close();        }        catch (Exception e)       {           System.out.println("Error message: " + e);       }    } } The above program creates a single employee record for employee number 002 with a last name of Newmann and a pay rate of 12.25. In the indicated space, create a statement that assigns the length of the string to RECSIZE .

(Short Answer)
4.8/5
(78)

A data file can be used as a(n) ____ file when each record is accessed one after another in the order in which it was stored.

(Multiple Choice)
4.8/5
(82)
Match each term with the correct statement below.
To make files no longer available to your application
System.getProperty("line.separator")
The main directory of your storage device
close the files
Returns the default line separator for a system
stream
Correct Answer:
Verified
Premises:
Responses:
To make files no longer available to your application
System.getProperty("line.separator")
The main directory of your storage device
close the files
Returns the default line separator for a system
stream
Writes text to an output stream, buffering the characters
batch processing
Functions as a pipeline or channel between a Java program and an input device
data file
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
buffer
The memory location where bytes are held after they are logically output but before they are sent to the output device
flushing
Involves performing the same tasks with many records
BufferedWriter
A collection of related records
root
(Matching)
4.8/5
(69)
Showing 61 - 66 of 66
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)