Files and I/O
- How to copy the file from one location to other?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Files.copy(source, target) is used to copy a file from one location to another. There are various options available like REPLACE_EXISTING, COPY_ATTRIBUTES and NOFOLLOW_LINKS.
- How can we get the size of specified file?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
size(Path) returns the size of the specified file in bytes.
- How to read entire file in one line using java 8?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Java 8 provides Files.readAllLines() which allows us to read entire file in one task. We do not need to worry about readers and writers.
- How can we create a symbolic link to file?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
createSymbolicLink() creates a symbolic link to a target.
- How can we filter lines based on content?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
lines.filter(line -> line.contains(“===—> Loaded package”)) can be used to filter out.