06 File Input and Output Flashcards

1
Q

It returns the String representation of the Path, eliminating double backslashes.

A

String toString()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Exception that is thrown if there is an attempt to delete a file without permission.

A

SecurityException

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the common characteristics of a text file and binary file?

A

Size
Name
Date
Time of creation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

It depends on other path information.

A

relative path

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Is a collection of fields that contain data about an entity. It is grouped to create files.

A

record

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Method that writes a single character.

A

write(int c)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Method that skips the specified number of characters.

A

skip(long n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Storage that is permanent. It is saved on a disk.

A

Non-volatile Storage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Method that flushes the stream.

A

flush()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

It is a complete path; it does not require any other information to locate a file on a system.

A

absolute path

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

It returns the name in position of the Path specified by the integer parameter.

A

Path getName(int)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When each record in a file is accessed one after another in the order in which it was stored, the data file is used as a ________ .

A

sequential access file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Method that can be used to remove a file without encountering an exception if the file does not exist.

A

deleteIfExists()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

It is being used when a Java program stores a value in a variable.

A

Random Access Memory (RAM)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Exception that is thrown if there is an attempt to delete a directory that has files.

A

DirectoryNotEmptyException

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the Path methods? (4)

A

String toString()
Path getFileName()
int getNameCount()
Path getName(int)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Exception that is thrown if there is an attempt to delete a file that does not exist.

A

NoSuchFileException

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

It is a memory location into which you can write data, which you can read again later.

A

buffer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

It performs operations on files and directories , such as determining their attributes, creating input and output streams, and deleting them.

A

Files class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Argument that opens the file if it exists or creates a new file if it hasn’t existed yet.

A

CREATE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What two (2) arguments that the readAttributes() method take?

A

Path object and BasicFileAttributes.class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What are the IO Classes? (10)

A

InputStream
FileInputStream
BufferedInputStream
OutputStream
FileOutputStream
BufferedOutputStream
PrintStream
Reader
BufferedReader
BufferedWriter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

It is the flow of data.

A

stream

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

It is the smallest useful piece of data.

A

character

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

It is a method that returns the size o the file in bytes.

A

size()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What are the common methods of the OutputStream Class? (4)

A

void close()
void flush()
void write(byte[] b)
void write(byte[] b, int off, int len)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

It creates objects that contain information about files and directories, such as sizes, locations, creation dates, and is used to check whether a file or directory exists.

A

Path class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Method that is used to convert a relative path to an absolute path.

A

toAbsolutePath()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Is a group of character that has some meaning. It is group together to form records.

A

field

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

A record’s fields cannot be organized into a single line or can be separated by a character. True or False?

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Argument that opens the file for writing.

A

WRITE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

What are the methods of the BufferedReader Class?

A

close()
read()
read(char[] buffer, int off, int len)
readLine()
skip(long n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Method that is used to create a writable file.

A

newOutputStream()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

A type of stream where data data is taken from a source and is delivered into a program.

A

input stream

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

Method used to verify if a file exists and if a program can access it when needed.

A

checkAccess()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

Argument that checks whether the file exists and whether the program has permission to execute the file.

A

EXECUTE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

Method that reads a single character.

A

read()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

Argument that appends new data to the end of the file.

A

APPEND

39
Q

Flushes the output stream; if any bytes are buffered, they will be written.

A

void flush()

40
Q

It returns the file or directory denoted by this Path; this is the last item in the sequence of name elements.

A

Path getFileName()

41
Q

What are the methods of the BufferedWriter?

A

close()
flush()
newline()
write(String s, int off, int len)
write(char[] array, int off, int len)
write(int c)

42
Q

Method that writes a character array from position off for length len.

A

write(char[] array, int off, int len)

43
Q

It is a method that returns the date and time the file was last edited.

A

lastModifiedTime()

44
Q

Handles input from a system’s standard or default input device.

A

BufferedInputStream

45
Q

Values in a record that are separated by commas are called?

A

comma-separated values

46
Q

What the two (2) types of storage devices?

A

Volatile storage and Non-volatile storage

47
Q

Method that writes a String from position off for length len.

A

write(String s, int off, int len)

48
Q

Arguments passed in the newOutputStream are Path and StandardOpenOption. True or False?

A

True

49
Q

Method that reads a line of text.

A

readLine()

50
Q

Writes all bytes to the output stream from the specified byte array.

A

void write(byte[] b)

51
Q

Is the format for creation time mm-dd-yyyyThh:mm:ss? True or False?

A

False. The format is: yyyy-mm-ddThh:mm:ss

52
Q

Method that closes the stream, flushing it first.

A

close()

53
Q

Contains methods for performing output that never throws an exception.

A

PrintStream

54
Q

Abstract class that contains method for performing output.

A

OutputStream

55
Q

It compares the relationship between values retrieved from creationTime() or lastModifiedTime().

A

compareTo()

56
Q

It consists of data that can be read in a text editor.

A

Text file

57
Q

What are the arguments of the checkAccess() method? (4)

A

None
READ
WRITE
EXECUTE

58
Q

What is the import used to use both the Path and Files class?

A

import java.nio.file.*;

59
Q

Abstract class for reading character streams.

A

Reader

60
Q

Permanent files are commonly stored in the home directory. True or False?

A

False. It is commonly stored in the main directory and root directory.

61
Q

Writes text to a character-output stream, buffering characters to provide for efficient writing of characters, arrays, and lines.

A

BufferedWriter

62
Q

Method used to retrieve useful information about a file.

A

readAttributes()

63
Q

Abstract class that contains method for performing input.

A

InputStream

64
Q

The complete list of the disk drive plus the hierarchy of directories in which the file is located is called ______ .

A

path

65
Q

Closes the output stream and releases any system resources associated with the stream.

A

void close()

66
Q

Argument that checks whether the file exists and whether the program has permission to read the file.

A

READ

67
Q

Argument that creates a new file only if it hasn’t existed yet; it throws an exception if the file already exists.

A

CREATE_NEW

68
Q

Writes bytes to the output stream form the specified byte array starting at offset position off for a length of len characters.

A

void write(byte[] b, int off, int len)

69
Q

What are the two (2) categories of a file?

A

Text file and binary file

70
Q

It contains data that is not encoded as text.

A

Binary file

71
Q

Argument that checks whether the file exists.

A

None

72
Q

Method of the Files class that is used to open a file for reading.

A

newInputStream()

73
Q

Provides the capability to read disk from files

A

FileInputStream

74
Q

Method of the Files class that accepts a Path parameter and removes the last element in a path or throws an exception if unsuccessful.

A

delete()

75
Q

Argument that deletes the file when the stream is closed; mostly used for temporary files that exist only for the duration of the program.

A

DELETE_ON_CLOSE

76
Q

It returns the number of name elements in the Path

A

int getNameCount()

77
Q

It consists of related records.

A

file

78
Q

Method that reads characters into a portion of a array rom position off for len characters.

A

read(char[] buffer, int off, int len)

79
Q

It is a method that returns the date and time the file was created.

A

creationTime()

80
Q

It clears any bytes that have been sent to a buffer for output but have not yet been displayed on a hardware device.

A

flushing

81
Q

It is a collection of data stored on a non-volatile device.

A

Computer File

82
Q

What are the arguments of the StandardOpenOption?

A

WRITE
APPEND
TRUNCATE_EXISTING
CREATE_NEW
CREATE
DELETE_ON_CLOSE

83
Q

Storage that is temporary. Values are lost when the computer loses its power.

A

Volatile Storage

84
Q

Method that writes a line separator.

A

newline()

85
Q

Argument that truncates the existing file to 0 yte so the file contents are replaced.

A

TRUNCATE_EXISTING

86
Q

It is a special character used to separate path components.

A

() path delimiter

87
Q

The readAttributes() method returns an instance of the BasicFileAttributes.class. True or False?

A

True

88
Q

Method that closes the stream and any resources associated with it.

A

close()

89
Q

Provides the capability to write to disk files.

A

FileOutputStream

90
Q

Reads text from a character-input stream, buffering characters to provide efficient reading of characters, arrays, and lines.

A

BufferedReader

91
Q

Handles input form a system’s standard or default output device.

A

BufferedOutputStream

92
Q

Argument that checks whether the file exists and whether the program has permission to write to the file.

A

WRITE

93
Q

A type of stream where data is delivered from a program to a destination.

A

output stream

94
Q

What are the methods of the BasicFileAttributes?

A

size()
creationTime()
lastModifiedTime()
compareTo()