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

Create a program that provides a listing of all the files in a directory. The pr

ID: 3724071 • Letter: C

Question

Create a program that provides a listing of all the files in a directory. The program should be a Java application that accepts a single argument into the args array of the main() method. This argument identifies the name of a directory. The application should make sure that this filename really does identify a directory and then list all of the files in the directory. For each file, list whether the file is a file or a directory and list the size for each file. The program should print its output to System.out.

Explanation / Answer

import java.io.File; public class ListFiles { public static void main(String[] args) { if(args.length > 0) { File dir = new File(args[0]); if(dir.isDirectory() && dir.exists()) { File files[] = dir.listFiles(); if(files != null) { for (int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote