COP 2805C (Advanced Java Programming) - File I/O and Data Streams

0.0(0)
studied byStudied by 5 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/30

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

31 Terms

1
New cards

What is non-volatile memory?

Memory that is maintained without power, such as hard drives.

2
New cards

What is volatile memory?

Memory that is lost when power is no longer applied, such as RAM.

3
New cards

What are files in the context of computer storage?

Data written to a disk.

4
New cards

What are streams in computing?

Data reservoirs that allow data to flow in and out of a program.

5
New cards

What does it mean when data is serialized?

Data is organized into a single continuous block of memory.

6
New cards

What are directories?

Path information to organize files.

7
New cards

What is a symbolic link?

File that contains a reference to another file.

8
New cards

What is the difference between absolute and relative paths?

Absolute paths contain the exact location of a file, while relative paths depend on the current directory.

9
New cards

How can you write OS-independent file path code in Java?

Use the FileSystem object to pull information about the machine and adapt to its path format.

10
New cards

What is the Path object in Java?

An object that breaks each folder in a file path into an array.

11
New cards

How do you create a file in Java?

Use Files.createFile(Path file) method.

12
New cards

How do you create a directory in Java?

Use Files.createDirectories(Path dir) method.

13
New cards

How can you delete a file or folder in Java?

Use Files.delete(Path path) or Files.deleteIfExists(Path path) methods.

14
New cards

How do you copy a file in Java?

Use Files.copy(Path source, Path target, StandardCopyOption.REPLACE_EXISTING) method.

15
New cards

How can you read an entire file into a byte array in Java?

Use Files.readAllBytes(Path path) method.

16
New cards

How do you write a list of strings to a file in Java?

Use Files.write(Path path, Iterable<? extends CharSequence> lines, Charset charset) method.

17
New cards

What are input and output streams used for?

Input streams read data from a source, and output streams write data to a destination.

18
New cards

What are the four types of streams for files in Java?

Reader, Writer, InputStream, and OutputStream.

19
New cards

How do you create an output stream for writing binary data in Java?

Use Files.newOutputStream(Path path, StandardOpenOption.CREATE, StandardOpenOption.APPEND) and wrap it in a BufferedOutputStream.

20
New cards

How can you read binary data using streams in Java?

Use Files.newInputStream(Path path, StandardOpenOption.READ) and wrap it in a BufferedInputStream.

21
New cards

How do you write text data to a file using PrintWriter in Java?

Create a PrintWriter wrapped around a BufferedWriter.

22
New cards

How do you read text data from a file using BufferedReader in Java?

Use Files.newBufferedReader(Path path, Charset charset) and read lines with BufferedReader.readLine().

23
New cards

What is serialization in Java?

The process of converting an object's state into a byte stream for storage or transmission.

24
New cards

Strength of Serialized Data

Easy to share

25
New cards

Weakness of Serialized Data

Can't easily use dynamic memory

26
New cards

Strength of Non-Serialized Data

Great for dynamic memory like linked lists

27
New cards

Weakness of Non-Serialized Data

Difficult to share

28
New cards

How do you make a Java object serializable?

Implement the java.io.Serializable interface in the class definition.

29
New cards

What is object deserialization in Java?

The process of converting a byte stream back into a copy of the original object.

30
New cards

How do you serialize an object in Java?

Use ObjectOutputStream to write the object to an OutputStream.

31
New cards

How do you deserialize an object in Java?

Use ObjectInputStream to read the object from an InputStream.