Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Kindly answer the vocabulary and the questions that follow. Java Programming 3-4

ID: 3852184 • Letter: K

Question

Kindly answer the vocabulary and the questions that follow.

Java Programming 3-4: Basics of Input and Output Practice Activities Lesson Objectives: Describe the basics of input and output in Java Read data from and write data to the console Vocabulary ldentify the vocabulary word for each definition below The physical name of a file, or a symbolic link name A type of node at the bottom of a top-down hierarchical (or inverted tree) that has no node below it. A file name that maps to another file A top-down single node hierarchy The top most node of a file system hierarchy, also known as a volume name, and used on the Linux operating system The top most node of a file system hierarchy, also known as a volume name, and used on the Windows operating system A hierarchy of elements, starting from a top-most (or root node) and moving down to nodes without any subordinate nodes Either a relative path, which may be some nodes and then a file name, a file name, or an absolute path with a file name as the last element, or leaf node This type of path starts with a logical mount, like C:l or D: in Windows, or a (forward slash) or combination of a forward slash and one or more node name, as long as its qualified as a mount point A hierarchy where the top-most node is the root and the bottom-most nodes are leaf nodes A path that starts somewhere other than the root node and ends in a file name The top most node of an absolute or relative path A specialized file that points to another absolute or relative file name Try It/Solve It: 1. Identify the main limitations of the Java.io Package

Explanation / Answer

The limitations of the java.io package

Program:

import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
class FileSystem {
    public void ReadDataFromFile()
    {
        String fileName = "c:\BlueJ\tempfiles\tempfile.txt";
Path path = Paths.get(fileName);
// This will reference one line at a time
String line = null;

try {
// FileReader reads text files in the default encoding.
FileReader fileReader =
new FileReader(path.toString());

// Always wrap FileReader in BufferedReader.
BufferedReader bufferedReader =
new BufferedReader(fileReader);

while((line = bufferedReader.readLine()) != null) {
System.out.println(line);
}   

// Always close files.
bufferedReader.close();   
}
catch(FileNotFoundException ex) {
System.out.println(
"Unable to open file '" +
path.toString() + "'");
}
catch(IOException ex) {
System.out.println(
"Error reading file '"
+ path.toString() + "'");
// Or we could just do this:
// ex.printStackTrace();
}
    }
public static void main(String [] args) {

FileSystem objFile=new FileSystem();
objFile.ReadDataFromFile();
  
}
}