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

Chapter 12.28 ( Rename files ) suppose you have a lot of files in a directory na

ID: 3864195 • Letter: C

Question

Chapter 12.28 (Rename files) suppose you have a lot of files in a directory named Exercisei_j, where i and j are digits. Write a program that pads a 0 before i if i is a single digit. For example, a file named Exercise2_1 in a directory will be renamed to Exercise02_1. In Java, when you pass the symbol * from the command line, it refers to all files in the directory (see Supplement III.V). Use the following command to run your program. Please explain code with comments .. I really don't unserstand. If external files are needed can toy send samples. Thanks

Explanation / Answer

/********************************************************************************* * (Rename files) Suppose you have a lot of files in a directory named * * Exercisei_j, where i and j are digits. Write a program that pads a 0 before i * * if i is a single digit. For example, a file named Exercise2_1 in a directory * * will be renamed to Exercise02_1. In Java, when you pass the symbol * from the * * command line, it refers to all files in the directory (see Supplement III.V). * * Use the following command to run your program. * *********************************************************************************/ import java.io.*; import java.util.*; public class Exercise_12_28 { /** Main method */ public static void main(String[] args) { // Check java command line usage if (args.length < 1) { System.out.println("Usage: java Exercise_12_28 *"); System.exit(1); } // Create an ArrayList of File objects ArrayList list = getFiles(args); // Pad each file's name in list 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