Deck 13: File Input and Output

ملء الشاشة (f)
exit full mode
سؤال
____ is an abstract class for reading character streams.

A) System.out
B) Reader
C) System.err
D) OutStream
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
You can use Java's ____ class to create objects that contain information about files or directories, such as their locations, sizes, creation dates, and whether they even exist.

A) Directory
B) Property
C) Path
D) File
سؤال
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.
سؤال
You can store data in variables within a program, but this type of storage is temporary.
سؤال
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.

A) application
B) sequential access
C) stream
D) field
سؤال
Permanent storage is usually called computer memory or random access memory (RAM).
سؤال
If you simply want to display records in order based on their key field, you need to create a random access file.
سؤال
InputStream is a child of FileInputStream .
سؤال
A ____ is a group of characters that has some meaning.

A) record
B) file
C) byte
D) field
سؤال
In random access files, records can be retrieved in any order.
سؤال
When you use the BufferedReader class, you must import the java.io package into your program.
سؤال
Java lets you assign a file to a(n) ____ object so that screen output and file output work in exactly the same manner.

A) Stream
B) Input
C) Output
D) File
سؤال
After you create a FileSystem object, you can define a Path using the ____ method with it.

A) getPath()
B) createPath()
C) setPath()
D) getDefault()
سؤال
The top-level element in a Path 's directory structure is located at index 1.
سؤال
Comma-separated values (CSV) is a file format strictly used for working with Java and databases.
سؤال
Placing a file in the ____ directory of your storage device is equivalent to tossing a loose document into a drawer.

A) root
B) path
C) back
D) loose
سؤال
Java's Path class is used to create objects that contain information about files and directories, while the Files class performs operations on files and directories.
سؤال
FileSystems is a class that contains ____ methods, which assist in object creation.

A) factory
B) file
C) abstract
D) system
سؤال
InputStream and OutputStream are subclasses of the ____ class.

A) IO
B) Object
C) Stream
D) IOStream
سؤال
Some text files are ____ files that contain facts and figures, such as a payroll file that contains employee numbers, names, and salaries.

A) application
B) volatile
C) data
D) program
سؤال
Because the backslash character starts the escape sequence in Java, you must use two ____ in a string that describes a Path in the DOS operating system.

A) dashes
B) quotes
C) backslashes
D) periods
سؤال
Any of the file input or output methods in a Java program might throw an exception, so all the relevant code in the class is placed in a ____ block.

A) finally
B) throw
C) try
D) catch
سؤال
Random files are also called ____ files.

A) direct access
B) indirect access
C) sequential
D) scannable
سؤال
When you use the BufferedReader class, you must import the ____ package into your program.

A) java.nio.file
B) java.io
C) java.nio
D) java.io.input
سؤال
A(n) ____ field is the field in a record that makes the record unique from all others.

A) unique
B) key
C) search
D) individual
سؤال
The value you store in memory is lost when the program ends or the computer loses power. This type of storage device is called ____.

A) random
B) sequential
C) volatile
D) nonvolatile
سؤال
The ____ method returns the last Path element in a list of pathnames.

A) toString()
B) getNameCount()
C) getFileName()
D) getName(int)
سؤال
You can use Java's ____ class to create your own random access files.

A) Path
B) FileStream
C) File
D) FileChannel
سؤال
The String class ____ method accepts an argument that identifies the field delimiter and returns an array of String s.

A) tokens()
B) divide()
C) tokenize()
D) split()
سؤال
____ is an abstract class that contains methods for performing output.

A) InputStream
B) OutputStream
C) println
D) FileInputStream
سؤال
A file channel is ____, meaning you can search for a specific file location and operations can start at any specified position.

A) moveable
B) seekable
C) flexible
D) dynamic
سؤال
The BufferedWriter class contains a ____ method that uses the current platform's line separator.

A) lineSeparator()
B) systemSeparator()
C) newLine()
D) newSeparator()
سؤال
You can create a writeable file by using the Files class ____ method.

A) getOutputStream()
B) newOutputStream()
C) newFileOutputStream()
D) fileOutputStream()
سؤال
Which of the following statements will write a line separator?

A) newline();
B) BufferedWriter.newline();
C) FileChannel.newline();
D) ByteBuffer.newline();
سؤال
A(n) ____ object is an avenue for reading and writing a file.

A) buffered
B) instant access file
C) batch processing
D) file channel
سؤال
A(n) ____ is a holding place for bytes that are waiting to be read or written.

A) ByteChannel
B) FileChannel
C) InputStream
D) ByteBuffer
سؤال
A(n) ____ is a collection of fields that contain data about an entity.

A) file
B) record
C) table
D) sequential access file
سؤال
____ applications require that a record be accessed immediately while a client is waiting.

A) Sequential
B) Dependent
C) Real-time
D) Batch
سؤال
The benefit of using a(n) ____ file is the ability to retrieve a specific record from a file directly, without reading through other records to locate the desired one.

A) random access
B) text
C) open
D) input
سؤال
An array of bytes can be wrapped, or encompassed, into a ByteBuffer using the ByteBuffer ____ method.

A) wrap()
B) convert()
C) export()
D) toArray()
سؤال
Match between columns
A collection of related records
batch processing
A collection of related records
root
A collection of related records
buffer
A collection of related records
flushing
A collection of related records
stream
A collection of related records
System.getProperty("line.separator")
A collection of related records
data file
A collection of related records
close the files
A collection of related records
BufferedWriter
A collection of related records
volatile storage
A collection of related records
static import feature
A collection of related records
seekable
A collection of related records
wrapped
A collection of related records
instant access files
A collection of related records
absolute path
سؤال
Match between columns
Writes text to an output stream, buffering the characters
batch processing
Writes text to an output stream, buffering the characters
root
Writes text to an output stream, buffering the characters
buffer
Writes text to an output stream, buffering the characters
flushing
Writes text to an output stream, buffering the characters
stream
Writes text to an output stream, buffering the characters
System.getProperty("line.separator")
Writes text to an output stream, buffering the characters
data file
Writes text to an output stream, buffering the characters
close the files
Writes text to an output stream, buffering the characters
BufferedWriter
Writes text to an output stream, buffering the characters
volatile storage
Writes text to an output stream, buffering the characters
static import feature
Writes text to an output stream, buffering the characters
seekable
Writes text to an output stream, buffering the characters
wrapped
Writes text to an output stream, buffering the characters
instant access files
Writes text to an output stream, buffering the characters
absolute path
سؤال
Match between columns
Same as random access files
batch processing
Same as random access files
root
Same as random access files
buffer
Same as random access files
flushing
Same as random access files
stream
Same as random access files
System.getProperty("line.separator")
Same as random access files
data file
Same as random access files
close the files
Same as random access files
BufferedWriter
Same as random access files
volatile storage
Same as random access files
static import feature
Same as random access files
seekable
Same as random access files
wrapped
Same as random access files
instant access files
Same as random access files
absolute path
سؤال
Match between columns
Involves performing the same tasks with many records
batch processing
Involves performing the same tasks with many records
root
Involves performing the same tasks with many records
buffer
Involves performing the same tasks with many records
flushing
Involves performing the same tasks with many records
stream
Involves performing the same tasks with many records
System.getProperty("line.separator")
Involves performing the same tasks with many records
data file
Involves performing the same tasks with many records
close the files
Involves performing the same tasks with many records
BufferedWriter
Involves performing the same tasks with many records
volatile storage
Involves performing the same tasks with many records
static import feature
Involves performing the same tasks with many records
seekable
Involves performing the same tasks with many records
wrapped
Involves performing the same tasks with many records
instant access files
Involves performing the same tasks with many records
absolute path
سؤال
Match between columns
Operations can start at any specified position
batch processing
Operations can start at any specified position
root
Operations can start at any specified position
buffer
Operations can start at any specified position
flushing
Operations can start at any specified position
stream
Operations can start at any specified position
System.getProperty("line.separator")
Operations can start at any specified position
data file
Operations can start at any specified position
close the files
Operations can start at any specified position
BufferedWriter
Operations can start at any specified position
volatile storage
Operations can start at any specified position
static import feature
Operations can start at any specified position
seekable
Operations can start at any specified position
wrapped
Operations can start at any specified position
instant access files
Operations can start at any specified position
absolute path
سؤال
Match between columns
A complete path
batch processing
A complete path
root
A complete path
buffer
A complete path
flushing
A complete path
stream
A complete path
System.getProperty("line.separator")
A complete path
data file
A complete path
close the files
A complete path
BufferedWriter
A complete path
volatile storage
A complete path
static import feature
A complete path
seekable
A complete path
wrapped
A complete path
instant access files
A complete path
absolute path
سؤال
Match between columns
Returns the default line separator for a system
batch processing
Returns the default line separator for a system
root
Returns the default line separator for a system
buffer
Returns the default line separator for a system
flushing
Returns the default line separator for a system
stream
Returns the default line separator for a system
System.getProperty("line.separator")
Returns the default line separator for a system
data file
Returns the default line separator for a system
close the files
Returns the default line separator for a system
BufferedWriter
Returns the default line separator for a system
volatile storage
Returns the default line separator for a system
static import feature
Returns the default line separator for a system
seekable
Returns the default line separator for a system
wrapped
Returns the default line separator for a system
instant access files
Returns the default line separator for a system
absolute path
سؤال
Match between columns
Functions as a pipeline or channel between a Java program and an input device
batch processing
Functions as a pipeline or channel between a Java program and an input device
root
Functions as a pipeline or channel between a Java program and an input device
buffer
Functions as a pipeline or channel between a Java program and an input device
flushing
Functions as a pipeline or channel between a Java program and an input device
stream
Functions as a pipeline or channel between a Java program and an input device
System.getProperty("line.separator")
Functions as a pipeline or channel between a Java program and an input device
data file
Functions as a pipeline or channel between a Java program and an input device
close the files
Functions as a pipeline or channel between a Java program and an input device
BufferedWriter
Functions as a pipeline or channel between a Java program and an input device
volatile storage
Functions as a pipeline or channel between a Java program and an input device
static import feature
Functions as a pipeline or channel between a Java program and an input device
seekable
Functions as a pipeline or channel between a Java program and an input device
wrapped
Functions as a pipeline or channel between a Java program and an input device
instant access files
Functions as a pipeline or channel between a Java program and an input device
absolute path
سؤال
Match between columns
Temporary storage
batch processing
Temporary storage
root
Temporary storage
buffer
Temporary storage
flushing
Temporary storage
stream
Temporary storage
System.getProperty("line.separator")
Temporary storage
data file
Temporary storage
close the files
Temporary storage
BufferedWriter
Temporary storage
volatile storage
Temporary storage
static import feature
Temporary storage
seekable
Temporary storage
wrapped
Temporary storage
instant access files
Temporary storage
absolute path
سؤال
Match between columns
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
batch processing
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
root
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
buffer
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
flushing
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
stream
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
System.getProperty("line.separator")
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware 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
close the files
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
BufferedWriter
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
volatile storage
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
static import feature
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
seekable
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
wrapped
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
instant access files
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
absolute path
سؤال
Match between columns
Encompassed
batch processing
Encompassed
root
Encompassed
buffer
Encompassed
flushing
Encompassed
stream
Encompassed
System.getProperty("line.separator")
Encompassed
data file
Encompassed
close the files
Encompassed
BufferedWriter
Encompassed
volatile storage
Encompassed
static import feature
Encompassed
seekable
Encompassed
wrapped
Encompassed
instant access files
Encompassed
absolute path
سؤال
Briefly describe the Path class in Java.
سؤال
Match between columns
To make files no longer available to your application
batch processing
To make files no longer available to your application
root
To make files no longer available to your application
buffer
To make files no longer available to your application
flushing
To make files no longer available to your application
stream
To make files no longer available to your application
System.getProperty("line.separator")
To make files no longer available to your application
data file
To make files no longer available to your application
close the files
To make files no longer available to your application
BufferedWriter
To make files no longer available to your application
volatile storage
To make files no longer available to your application
static import feature
To make files no longer available to your application
seekable
To make files no longer available to your application
wrapped
To make files no longer available to your application
instant access files
To make files no longer available to your application
absolute path
سؤال
How can you categorize files by the way they store data?
سؤال
Match between columns
Allows you to use static constants without their class name
batch processing
Allows you to use static constants without their class name
root
Allows you to use static constants without their class name
buffer
Allows you to use static constants without their class name
flushing
Allows you to use static constants without their class name
stream
Allows you to use static constants without their class name
System.getProperty("line.separator")
Allows you to use static constants without their class name
data file
Allows you to use static constants without their class name
close the files
Allows you to use static constants without their class name
BufferedWriter
Allows you to use static constants without their class name
volatile storage
Allows you to use static constants without their class name
static import feature
Allows you to use static constants without their class name
seekable
Allows you to use static constants without their class name
wrapped
Allows you to use static constants without their class name
instant access files
Allows you to use static constants without their class name
absolute path
سؤال
What tasks are typically performed when working with stored files in an application?
سؤال
When you perform input and output operations in an application, what is actually occurring with the bytes of information?
سؤال
What is the difference between volatile and nonvolatile storage in Java programming? Give examples of different storage situations.
سؤال
Match between columns
The main directory of your storage device
batch processing
The main directory of your storage device
root
The main directory of your storage device
buffer
The main directory of your storage device
flushing
The main directory of your storage device
stream
The main directory of your storage device
System.getProperty("line.separator")
The main directory of your storage device
data file
The main directory of your storage device
close the files
The main directory of your storage device
BufferedWriter
The main directory of your storage device
volatile storage
The main directory of your storage device
static import feature
The main directory of your storage device
seekable
The main directory of your storage device
wrapped
The main directory of your storage device
instant access files
The main directory of your storage device
absolute path
سؤال
Match between columns
The memory location where bytes are held after they are logically output but before they are sent to the output device
batch processing
The memory location where bytes are held after they are logically output but before they are sent to the output device
root
The memory location where bytes are held after they are logically output but before they are sent to the output device
buffer
The memory location where bytes are held after they are logically output but before they are sent to the output device
flushing
The memory location where bytes are held after they are logically output but before they are sent to the output device
stream
The memory location where bytes are held after they are logically output but before they are sent to the output device
System.getProperty("line.separator")
The memory location where bytes are held after they are logically output but before they are sent to the output device
data file
The memory location where bytes are held after they are logically output but before they are sent to the output device
close the files
The memory location where bytes are held after they are logically output but before they are sent to the output device
BufferedWriter
The memory location where bytes are held after they are logically output but before they are sent to the output device
volatile storage
The memory location where bytes are held after they are logically output but before they are sent to the output device
static import feature
The memory location where bytes are held after they are logically output but before they are sent to the output device
seekable
The memory location where bytes are held after they are logically output but before they are sent to the output device
wrapped
The memory location where bytes are held after they are logically output but before they are sent to the output device
instant access files
The memory location where bytes are held after they are logically output but before they are sent to the output device
absolute path
سؤال
while(nextLine = reader.readLine() != null)
    System.out.println(nextLine);
The above loop could be used to read multiple lines from a file. Explain how this loop will execute.
سؤال
import java.nio.file.*;
import java.io.*;
public class ReadEmployeeFile
{
   public static void main(String[] args)
   {
      Path file =
        Paths.get("C:\\Java\\Chapter.13\\Employees.txt");
      String s = "";
      try
      {
         InputStream input = new
           BufferedInputStream(Files.newInputStream(file));
         BufferedReader reader = new
           BufferedReader(new InputStreamReader(input));
         -----Code here-----
         while(s != null)
         {
             System.out.println(s);
             -----Code here-----
         }
         reader.close();
     }
     catch(Exception e)
     {
        System.out.println("Message: " + e);
     }
   }
}
The above code represents a program that reads an Employees text file. An InputStream is declared for the file, and a BufferedReader is created using the InputStream . On the indicated lines, write a statement that will read the first line into the String . Likewise, in the while statement, write the statement to display the String and read a new line as long as the readLine() method does not return a null value.
سؤال
How can you write the system's newline character to a file in Java?
سؤال
import java.nio.file.*;
import java.io.*;
import static java.nio.file.StandardOpenOption.*;
public class WriteFile
{
   public static void main(String[] args)
   {
      Path myFile = Paths.get("C:\\Java\\Input.Output\\myNumbers.txt");
      String nums = "12345";
      byte[] data = nums.getBytes();
      OutputStream output = null;
      try
     {
       -----Code here------
       output.write(data)
       output.flush();
       output.close();
     }
     catch(Exception badNums)
     {
         System.out.println("My numbers: " + badNums);
     }
  }
}
Using the above code, add a statement on the indicated line that will create a writeable file by constructing a BufferedOutputStream object and assigning it to the OutputStream . No output should appear on the monitor, but a file should be created.
سؤال
import java.nio.file.*;
import static java.nio.file.AccessMode.*;
import java.io.IOException;
public class PathDemo3
{
  public static void main(String[] args)
  {
    Path myFile = Paths.get("C:\\Java\\Chapter.13\\Data.txt");
    System.out.println("Path is " + myFile.toString());
    try     {
      -------------- Code here -------------------
      System.out.println("File can be read and executed");     }
    catch(IOException e)
    {
       System.out.println("File cannot be used for this application");
    }
   }
}
Assuming you have declared a path named myFile , create the checkAccess() method on the indicated line that will verify that the file exists, and checks that the program can read and write to the file.
سؤال
Provide an example of batch processing.
سؤال
Explain the difference between an absolute path and a relative path. Provide an example of an absolute path to a file on a system, and then provide an example of a relative path.
سؤال
When a String is written, placing each record on a new line makes the output file easier to read and interpret. Since not all platforms use '\n' to separate lines, the BufferedWriter class has two alternatives: the newLine() method and the System.getProperty() method. Describe these two methods and how they operate.
سؤال
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.io.IOException;
public class PathDemo5
{
  public static void main(String[] args)
  {
      Path myPath = Paths.get("C:\\Java\\Input.Output\\MyData.txt");
      try
      {
         ---------Code here ----------
         System.out.println("Creation time " + attr.creationTime());
         System.out.println("Last modified time " + attr.lastModifiedTime());
         System.out.println("Size " + attr.size());
      }
      catch(IOException e)
      {
         System.out.println("IO Exception");
      }
  }
}
Using the above code, create a statement on the indicated line that uses the readAttributes() method of the Files class that takes two arguments-the Path object created in the code and a BasicFileAttributes.class -and returns an instance of the BasicFileAttributes class named attr .
سؤال
FileChannel fc = null;
Path file =
Paths.get("C:\\Java\\Chapter.13\\RandomEmployees.txt");
Given the two declarations above, write a Java statement that creates a ByteChannel that is cast to a FileChannel . The file shoould be open for read and write operations.
سؤال
Describe and provide an example of the differences between real-time applications and interactive programs.
سؤال
import java.util.Scanner;
import java.nio.file.*;
public class PathDemo2
{
    public static void main(String[] args)
    {
       String name;
       Scanner keyboard = new Scanner(System.in);
       System.out.print("Enter a file name >> ");
       name = keyboard.nextLine();
       Path inputPath = Paths.get(name);
       ------- Code here -----
       System.out.println("Full path is " + fullPath.toString());
    }
}
Using the above code, add a statement on the indicated line that creates an absolute path by assigning the file to the current directory.
سؤال
import java.nio.file.*;
public class PathDemo
{
    public static void main(String[] args)
    {
        Path filePath = Paths.get("C:\\Java\\Input.Output\\LessonInfo.txt");
        int count = filePath.getNameCount();
        System.out.println("Path is " + filePath.toString());
        System.out.println("File name is " +
          filePath.getFileName());
        System.out.println("There are " + count +
          " elements in the file path");
        for(int x = 0; x < count; ++x)
            System.out.println("Element " + x + " is " +
            filePath.getName(x));
    }
}
The above code demonstrates the creation of a Path and its method. Describe the output that will display when the code is executed.
سؤال
How can you assign program output to a file, rather than to the standard output device? Explain how this works. Give an example.
سؤال
import java.nio.file.*;
import java.io.*;
public class ReadEmployeeFile2
{
   public static void main(String[] args)
   {
      Path file =
        Paths.get("C:\\Java\\Chapter.13\\Employees.txt");
     String[] array = new String[3];
     String s = "";
     String delimiter = ",";
     int id;
     String name;
     double payRate;
     double gross;
     final double HRS_IN_WEEK = 40;
     double total = 0;
     try
     {
        InputStream input = new
            BufferedInputStream(Files.newInputStream(file));
        BufferedReader reader = new
           BufferedReader(new InputStreamReader(input));
        System.out.println();
        s = reader.readLine();
        while(s != null)
        {
           -----Code here-----
           id = Integer.parseInt(array[0]);
           name = array[1];
           payRate = Double.parseDouble(array[2]);
           gross = payRate * HRS_IN_WEEK;
           System.out.println("ID#" + id + " " + name +
             " $" + payRate + " $" + gross);
           total += gross;
           s = reader.readLine();
       }
       reader.close();
   }
   catch(Exception e)
   {
       System.out.println("Message: " + e);
    }
   System.out.println(" Total gross payroll is $" + total);
   }
}
The above code demonstrates a retrieved file where Strings are split into usable fields. On the indicated line, write a String class split() method to split the String s that accepts an argument that identifies the field delimiter (in this example, a comma) and returns an array of Strings . The result should be assigned to the String[] array .
سؤال
import java.nio.file.*;
import java.io.*;
public class ReadFile
{
    public static void main(String[] args)
   {
       Path file = Paths.get("C:\\Java\\Input.Output\\Grades.txt");
       InputStream input = null;
       try
      {
          ----Code here-------
          ----Code here-------
           String grade = null;
           grade = reader.readLine();
           System.out.println(grade);
           input.close();
       }
       catch (IOException e)
      {
          System.out.println(e);
       }
   }
} In the code above, a ReadFile class reads from the Grades.txt file. A path is declared, and an InputStream is declared using the Path . In the first indicated line, create the statement to assign a stream to the InputStream reference. In the second indicated line, declare a BufferedReader that reads a line of text from a character-input stream that buffers characters for more efficient reading.
سؤال
writer.write(names, 0, names.length());
The above code represents a write() method of the BufferedWriter class. Describe the purpose of the method and how it accepts the String characters.
سؤال
Briefly describe the ByteBuffer class.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/78
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 13: File Input and Output
1
____ is an abstract class for reading character streams.

A) System.out
B) Reader
C) System.err
D) OutStream
B
2
You can use Java's ____ class to create objects that contain information about files or directories, such as their locations, sizes, creation dates, and whether they even exist.

A) Directory
B) Property
C) Path
D) File
C
3
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.
False
4
You can store data in variables within a program, but this type of storage is temporary.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
5
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.

A) application
B) sequential access
C) stream
D) field
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
6
Permanent storage is usually called computer memory or random access memory (RAM).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
7
If you simply want to display records in order based on their key field, you need to create a random access file.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
8
InputStream is a child of FileInputStream .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
9
A ____ is a group of characters that has some meaning.

A) record
B) file
C) byte
D) field
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
10
In random access files, records can be retrieved in any order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
11
When you use the BufferedReader class, you must import the java.io package into your program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
12
Java lets you assign a file to a(n) ____ object so that screen output and file output work in exactly the same manner.

A) Stream
B) Input
C) Output
D) File
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
13
After you create a FileSystem object, you can define a Path using the ____ method with it.

A) getPath()
B) createPath()
C) setPath()
D) getDefault()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
14
The top-level element in a Path 's directory structure is located at index 1.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
15
Comma-separated values (CSV) is a file format strictly used for working with Java and databases.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
16
Placing a file in the ____ directory of your storage device is equivalent to tossing a loose document into a drawer.

A) root
B) path
C) back
D) loose
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
17
Java's Path class is used to create objects that contain information about files and directories, while the Files class performs operations on files and directories.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
18
FileSystems is a class that contains ____ methods, which assist in object creation.

A) factory
B) file
C) abstract
D) system
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
19
InputStream and OutputStream are subclasses of the ____ class.

A) IO
B) Object
C) Stream
D) IOStream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
20
Some text files are ____ files that contain facts and figures, such as a payroll file that contains employee numbers, names, and salaries.

A) application
B) volatile
C) data
D) program
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
21
Because the backslash character starts the escape sequence in Java, you must use two ____ in a string that describes a Path in the DOS operating system.

A) dashes
B) quotes
C) backslashes
D) periods
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
22
Any of the file input or output methods in a Java program might throw an exception, so all the relevant code in the class is placed in a ____ block.

A) finally
B) throw
C) try
D) catch
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
23
Random files are also called ____ files.

A) direct access
B) indirect access
C) sequential
D) scannable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
24
When you use the BufferedReader class, you must import the ____ package into your program.

A) java.nio.file
B) java.io
C) java.nio
D) java.io.input
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
25
A(n) ____ field is the field in a record that makes the record unique from all others.

A) unique
B) key
C) search
D) individual
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
26
The value you store in memory is lost when the program ends or the computer loses power. This type of storage device is called ____.

A) random
B) sequential
C) volatile
D) nonvolatile
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
27
The ____ method returns the last Path element in a list of pathnames.

A) toString()
B) getNameCount()
C) getFileName()
D) getName(int)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
28
You can use Java's ____ class to create your own random access files.

A) Path
B) FileStream
C) File
D) FileChannel
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
29
The String class ____ method accepts an argument that identifies the field delimiter and returns an array of String s.

A) tokens()
B) divide()
C) tokenize()
D) split()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
30
____ is an abstract class that contains methods for performing output.

A) InputStream
B) OutputStream
C) println
D) FileInputStream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
31
A file channel is ____, meaning you can search for a specific file location and operations can start at any specified position.

A) moveable
B) seekable
C) flexible
D) dynamic
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
32
The BufferedWriter class contains a ____ method that uses the current platform's line separator.

A) lineSeparator()
B) systemSeparator()
C) newLine()
D) newSeparator()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
33
You can create a writeable file by using the Files class ____ method.

A) getOutputStream()
B) newOutputStream()
C) newFileOutputStream()
D) fileOutputStream()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
34
Which of the following statements will write a line separator?

A) newline();
B) BufferedWriter.newline();
C) FileChannel.newline();
D) ByteBuffer.newline();
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
35
A(n) ____ object is an avenue for reading and writing a file.

A) buffered
B) instant access file
C) batch processing
D) file channel
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
36
A(n) ____ is a holding place for bytes that are waiting to be read or written.

A) ByteChannel
B) FileChannel
C) InputStream
D) ByteBuffer
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
37
A(n) ____ is a collection of fields that contain data about an entity.

A) file
B) record
C) table
D) sequential access file
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
38
____ applications require that a record be accessed immediately while a client is waiting.

A) Sequential
B) Dependent
C) Real-time
D) Batch
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
39
The benefit of using a(n) ____ file is the ability to retrieve a specific record from a file directly, without reading through other records to locate the desired one.

A) random access
B) text
C) open
D) input
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
40
An array of bytes can be wrapped, or encompassed, into a ByteBuffer using the ByteBuffer ____ method.

A) wrap()
B) convert()
C) export()
D) toArray()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
41
Match between columns
A collection of related records
batch processing
A collection of related records
root
A collection of related records
buffer
A collection of related records
flushing
A collection of related records
stream
A collection of related records
System.getProperty("line.separator")
A collection of related records
data file
A collection of related records
close the files
A collection of related records
BufferedWriter
A collection of related records
volatile storage
A collection of related records
static import feature
A collection of related records
seekable
A collection of related records
wrapped
A collection of related records
instant access files
A collection of related records
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
42
Match between columns
Writes text to an output stream, buffering the characters
batch processing
Writes text to an output stream, buffering the characters
root
Writes text to an output stream, buffering the characters
buffer
Writes text to an output stream, buffering the characters
flushing
Writes text to an output stream, buffering the characters
stream
Writes text to an output stream, buffering the characters
System.getProperty("line.separator")
Writes text to an output stream, buffering the characters
data file
Writes text to an output stream, buffering the characters
close the files
Writes text to an output stream, buffering the characters
BufferedWriter
Writes text to an output stream, buffering the characters
volatile storage
Writes text to an output stream, buffering the characters
static import feature
Writes text to an output stream, buffering the characters
seekable
Writes text to an output stream, buffering the characters
wrapped
Writes text to an output stream, buffering the characters
instant access files
Writes text to an output stream, buffering the characters
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
43
Match between columns
Same as random access files
batch processing
Same as random access files
root
Same as random access files
buffer
Same as random access files
flushing
Same as random access files
stream
Same as random access files
System.getProperty("line.separator")
Same as random access files
data file
Same as random access files
close the files
Same as random access files
BufferedWriter
Same as random access files
volatile storage
Same as random access files
static import feature
Same as random access files
seekable
Same as random access files
wrapped
Same as random access files
instant access files
Same as random access files
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
44
Match between columns
Involves performing the same tasks with many records
batch processing
Involves performing the same tasks with many records
root
Involves performing the same tasks with many records
buffer
Involves performing the same tasks with many records
flushing
Involves performing the same tasks with many records
stream
Involves performing the same tasks with many records
System.getProperty("line.separator")
Involves performing the same tasks with many records
data file
Involves performing the same tasks with many records
close the files
Involves performing the same tasks with many records
BufferedWriter
Involves performing the same tasks with many records
volatile storage
Involves performing the same tasks with many records
static import feature
Involves performing the same tasks with many records
seekable
Involves performing the same tasks with many records
wrapped
Involves performing the same tasks with many records
instant access files
Involves performing the same tasks with many records
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
45
Match between columns
Operations can start at any specified position
batch processing
Operations can start at any specified position
root
Operations can start at any specified position
buffer
Operations can start at any specified position
flushing
Operations can start at any specified position
stream
Operations can start at any specified position
System.getProperty("line.separator")
Operations can start at any specified position
data file
Operations can start at any specified position
close the files
Operations can start at any specified position
BufferedWriter
Operations can start at any specified position
volatile storage
Operations can start at any specified position
static import feature
Operations can start at any specified position
seekable
Operations can start at any specified position
wrapped
Operations can start at any specified position
instant access files
Operations can start at any specified position
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
46
Match between columns
A complete path
batch processing
A complete path
root
A complete path
buffer
A complete path
flushing
A complete path
stream
A complete path
System.getProperty("line.separator")
A complete path
data file
A complete path
close the files
A complete path
BufferedWriter
A complete path
volatile storage
A complete path
static import feature
A complete path
seekable
A complete path
wrapped
A complete path
instant access files
A complete path
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
47
Match between columns
Returns the default line separator for a system
batch processing
Returns the default line separator for a system
root
Returns the default line separator for a system
buffer
Returns the default line separator for a system
flushing
Returns the default line separator for a system
stream
Returns the default line separator for a system
System.getProperty("line.separator")
Returns the default line separator for a system
data file
Returns the default line separator for a system
close the files
Returns the default line separator for a system
BufferedWriter
Returns the default line separator for a system
volatile storage
Returns the default line separator for a system
static import feature
Returns the default line separator for a system
seekable
Returns the default line separator for a system
wrapped
Returns the default line separator for a system
instant access files
Returns the default line separator for a system
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
48
Match between columns
Functions as a pipeline or channel between a Java program and an input device
batch processing
Functions as a pipeline or channel between a Java program and an input device
root
Functions as a pipeline or channel between a Java program and an input device
buffer
Functions as a pipeline or channel between a Java program and an input device
flushing
Functions as a pipeline or channel between a Java program and an input device
stream
Functions as a pipeline or channel between a Java program and an input device
System.getProperty("line.separator")
Functions as a pipeline or channel between a Java program and an input device
data file
Functions as a pipeline or channel between a Java program and an input device
close the files
Functions as a pipeline or channel between a Java program and an input device
BufferedWriter
Functions as a pipeline or channel between a Java program and an input device
volatile storage
Functions as a pipeline or channel between a Java program and an input device
static import feature
Functions as a pipeline or channel between a Java program and an input device
seekable
Functions as a pipeline or channel between a Java program and an input device
wrapped
Functions as a pipeline or channel between a Java program and an input device
instant access files
Functions as a pipeline or channel between a Java program and an input device
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
49
Match between columns
Temporary storage
batch processing
Temporary storage
root
Temporary storage
buffer
Temporary storage
flushing
Temporary storage
stream
Temporary storage
System.getProperty("line.separator")
Temporary storage
data file
Temporary storage
close the files
Temporary storage
BufferedWriter
Temporary storage
volatile storage
Temporary storage
static import feature
Temporary storage
seekable
Temporary storage
wrapped
Temporary storage
instant access files
Temporary storage
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
50
Match between columns
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
batch processing
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
root
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
buffer
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
flushing
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
stream
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
System.getProperty("line.separator")
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware 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
close the files
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
BufferedWriter
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
volatile storage
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
static import feature
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
seekable
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
wrapped
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
instant access files
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
51
Match between columns
Encompassed
batch processing
Encompassed
root
Encompassed
buffer
Encompassed
flushing
Encompassed
stream
Encompassed
System.getProperty("line.separator")
Encompassed
data file
Encompassed
close the files
Encompassed
BufferedWriter
Encompassed
volatile storage
Encompassed
static import feature
Encompassed
seekable
Encompassed
wrapped
Encompassed
instant access files
Encompassed
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
52
Briefly describe the Path class in Java.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
53
Match between columns
To make files no longer available to your application
batch processing
To make files no longer available to your application
root
To make files no longer available to your application
buffer
To make files no longer available to your application
flushing
To make files no longer available to your application
stream
To make files no longer available to your application
System.getProperty("line.separator")
To make files no longer available to your application
data file
To make files no longer available to your application
close the files
To make files no longer available to your application
BufferedWriter
To make files no longer available to your application
volatile storage
To make files no longer available to your application
static import feature
To make files no longer available to your application
seekable
To make files no longer available to your application
wrapped
To make files no longer available to your application
instant access files
To make files no longer available to your application
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
54
How can you categorize files by the way they store data?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
55
Match between columns
Allows you to use static constants without their class name
batch processing
Allows you to use static constants without their class name
root
Allows you to use static constants without their class name
buffer
Allows you to use static constants without their class name
flushing
Allows you to use static constants without their class name
stream
Allows you to use static constants without their class name
System.getProperty("line.separator")
Allows you to use static constants without their class name
data file
Allows you to use static constants without their class name
close the files
Allows you to use static constants without their class name
BufferedWriter
Allows you to use static constants without their class name
volatile storage
Allows you to use static constants without their class name
static import feature
Allows you to use static constants without their class name
seekable
Allows you to use static constants without their class name
wrapped
Allows you to use static constants without their class name
instant access files
Allows you to use static constants without their class name
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
56
What tasks are typically performed when working with stored files in an application?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
57
When you perform input and output operations in an application, what is actually occurring with the bytes of information?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
58
What is the difference between volatile and nonvolatile storage in Java programming? Give examples of different storage situations.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
59
Match between columns
The main directory of your storage device
batch processing
The main directory of your storage device
root
The main directory of your storage device
buffer
The main directory of your storage device
flushing
The main directory of your storage device
stream
The main directory of your storage device
System.getProperty("line.separator")
The main directory of your storage device
data file
The main directory of your storage device
close the files
The main directory of your storage device
BufferedWriter
The main directory of your storage device
volatile storage
The main directory of your storage device
static import feature
The main directory of your storage device
seekable
The main directory of your storage device
wrapped
The main directory of your storage device
instant access files
The main directory of your storage device
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
60
Match between columns
The memory location where bytes are held after they are logically output but before they are sent to the output device
batch processing
The memory location where bytes are held after they are logically output but before they are sent to the output device
root
The memory location where bytes are held after they are logically output but before they are sent to the output device
buffer
The memory location where bytes are held after they are logically output but before they are sent to the output device
flushing
The memory location where bytes are held after they are logically output but before they are sent to the output device
stream
The memory location where bytes are held after they are logically output but before they are sent to the output device
System.getProperty("line.separator")
The memory location where bytes are held after they are logically output but before they are sent to the output device
data file
The memory location where bytes are held after they are logically output but before they are sent to the output device
close the files
The memory location where bytes are held after they are logically output but before they are sent to the output device
BufferedWriter
The memory location where bytes are held after they are logically output but before they are sent to the output device
volatile storage
The memory location where bytes are held after they are logically output but before they are sent to the output device
static import feature
The memory location where bytes are held after they are logically output but before they are sent to the output device
seekable
The memory location where bytes are held after they are logically output but before they are sent to the output device
wrapped
The memory location where bytes are held after they are logically output but before they are sent to the output device
instant access files
The memory location where bytes are held after they are logically output but before they are sent to the output device
absolute path
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
61
while(nextLine = reader.readLine() != null)
    System.out.println(nextLine);
The above loop could be used to read multiple lines from a file. Explain how this loop will execute.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
62
import java.nio.file.*;
import java.io.*;
public class ReadEmployeeFile
{
   public static void main(String[] args)
   {
      Path file =
        Paths.get("C:\\Java\\Chapter.13\\Employees.txt");
      String s = "";
      try
      {
         InputStream input = new
           BufferedInputStream(Files.newInputStream(file));
         BufferedReader reader = new
           BufferedReader(new InputStreamReader(input));
         -----Code here-----
         while(s != null)
         {
             System.out.println(s);
             -----Code here-----
         }
         reader.close();
     }
     catch(Exception e)
     {
        System.out.println("Message: " + e);
     }
   }
}
The above code represents a program that reads an Employees text file. An InputStream is declared for the file, and a BufferedReader is created using the InputStream . On the indicated lines, write a statement that will read the first line into the String . Likewise, in the while statement, write the statement to display the String and read a new line as long as the readLine() method does not return a null value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
63
How can you write the system's newline character to a file in Java?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
64
import java.nio.file.*;
import java.io.*;
import static java.nio.file.StandardOpenOption.*;
public class WriteFile
{
   public static void main(String[] args)
   {
      Path myFile = Paths.get("C:\\Java\\Input.Output\\myNumbers.txt");
      String nums = "12345";
      byte[] data = nums.getBytes();
      OutputStream output = null;
      try
     {
       -----Code here------
       output.write(data)
       output.flush();
       output.close();
     }
     catch(Exception badNums)
     {
         System.out.println("My numbers: " + badNums);
     }
  }
}
Using the above code, add a statement on the indicated line that will create a writeable file by constructing a BufferedOutputStream object and assigning it to the OutputStream . No output should appear on the monitor, but a file should be created.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
65
import java.nio.file.*;
import static java.nio.file.AccessMode.*;
import java.io.IOException;
public class PathDemo3
{
  public static void main(String[] args)
  {
    Path myFile = Paths.get("C:\\Java\\Chapter.13\\Data.txt");
    System.out.println("Path is " + myFile.toString());
    try     {
      -------------- Code here -------------------
      System.out.println("File can be read and executed");     }
    catch(IOException e)
    {
       System.out.println("File cannot be used for this application");
    }
   }
}
Assuming you have declared a path named myFile , create the checkAccess() method on the indicated line that will verify that the file exists, and checks that the program can read and write to the file.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
66
Provide an example of batch processing.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
67
Explain the difference between an absolute path and a relative path. Provide an example of an absolute path to a file on a system, and then provide an example of a relative path.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
68
When a String is written, placing each record on a new line makes the output file easier to read and interpret. Since not all platforms use '\n' to separate lines, the BufferedWriter class has two alternatives: the newLine() method and the System.getProperty() method. Describe these two methods and how they operate.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
69
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.io.IOException;
public class PathDemo5
{
  public static void main(String[] args)
  {
      Path myPath = Paths.get("C:\\Java\\Input.Output\\MyData.txt");
      try
      {
         ---------Code here ----------
         System.out.println("Creation time " + attr.creationTime());
         System.out.println("Last modified time " + attr.lastModifiedTime());
         System.out.println("Size " + attr.size());
      }
      catch(IOException e)
      {
         System.out.println("IO Exception");
      }
  }
}
Using the above code, create a statement on the indicated line that uses the readAttributes() method of the Files class that takes two arguments-the Path object created in the code and a BasicFileAttributes.class -and returns an instance of the BasicFileAttributes class named attr .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
70
FileChannel fc = null;
Path file =
Paths.get("C:\\Java\\Chapter.13\\RandomEmployees.txt");
Given the two declarations above, write a Java statement that creates a ByteChannel that is cast to a FileChannel . The file shoould be open for read and write operations.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
71
Describe and provide an example of the differences between real-time applications and interactive programs.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
72
import java.util.Scanner;
import java.nio.file.*;
public class PathDemo2
{
    public static void main(String[] args)
    {
       String name;
       Scanner keyboard = new Scanner(System.in);
       System.out.print("Enter a file name >> ");
       name = keyboard.nextLine();
       Path inputPath = Paths.get(name);
       ------- Code here -----
       System.out.println("Full path is " + fullPath.toString());
    }
}
Using the above code, add a statement on the indicated line that creates an absolute path by assigning the file to the current directory.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
73
import java.nio.file.*;
public class PathDemo
{
    public static void main(String[] args)
    {
        Path filePath = Paths.get("C:\\Java\\Input.Output\\LessonInfo.txt");
        int count = filePath.getNameCount();
        System.out.println("Path is " + filePath.toString());
        System.out.println("File name is " +
          filePath.getFileName());
        System.out.println("There are " + count +
          " elements in the file path");
        for(int x = 0; x < count; ++x)
            System.out.println("Element " + x + " is " +
            filePath.getName(x));
    }
}
The above code demonstrates the creation of a Path and its method. Describe the output that will display when the code is executed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
74
How can you assign program output to a file, rather than to the standard output device? Explain how this works. Give an example.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
75
import java.nio.file.*;
import java.io.*;
public class ReadEmployeeFile2
{
   public static void main(String[] args)
   {
      Path file =
        Paths.get("C:\\Java\\Chapter.13\\Employees.txt");
     String[] array = new String[3];
     String s = "";
     String delimiter = ",";
     int id;
     String name;
     double payRate;
     double gross;
     final double HRS_IN_WEEK = 40;
     double total = 0;
     try
     {
        InputStream input = new
            BufferedInputStream(Files.newInputStream(file));
        BufferedReader reader = new
           BufferedReader(new InputStreamReader(input));
        System.out.println();
        s = reader.readLine();
        while(s != null)
        {
           -----Code here-----
           id = Integer.parseInt(array[0]);
           name = array[1];
           payRate = Double.parseDouble(array[2]);
           gross = payRate * HRS_IN_WEEK;
           System.out.println("ID#" + id + " " + name +
             " $" + payRate + " $" + gross);
           total += gross;
           s = reader.readLine();
       }
       reader.close();
   }
   catch(Exception e)
   {
       System.out.println("Message: " + e);
    }
   System.out.println(" Total gross payroll is $" + total);
   }
}
The above code demonstrates a retrieved file where Strings are split into usable fields. On the indicated line, write a String class split() method to split the String s that accepts an argument that identifies the field delimiter (in this example, a comma) and returns an array of Strings . The result should be assigned to the String[] array .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
76
import java.nio.file.*;
import java.io.*;
public class ReadFile
{
    public static void main(String[] args)
   {
       Path file = Paths.get("C:\\Java\\Input.Output\\Grades.txt");
       InputStream input = null;
       try
      {
          ----Code here-------
          ----Code here-------
           String grade = null;
           grade = reader.readLine();
           System.out.println(grade);
           input.close();
       }
       catch (IOException e)
      {
          System.out.println(e);
       }
   }
} In the code above, a ReadFile class reads from the Grades.txt file. A path is declared, and an InputStream is declared using the Path . In the first indicated line, create the statement to assign a stream to the InputStream reference. In the second indicated line, declare a BufferedReader that reads a line of text from a character-input stream that buffers characters for more efficient reading.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
77
writer.write(names, 0, names.length());
The above code represents a write() method of the BufferedWriter class. Describe the purpose of the method and how it accepts the String characters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
78
Briefly describe the ByteBuffer class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 78 في هذه المجموعة.