Display executable files in directory Java Exercise - Java Programming Course


Display executable files in directory


Create a program that shows the names (excluding the path) of all executable files (.com, .exe, .bat, .cmd) in the current folder.

 Example Code

public class Main
	public static void main()
		String[] files = (new java.io.File(".")).list(java.io.File::isFile);

		for (String file : files)
			String extension = Path.GetExtension(file);

			switch (extension)
				case ".exe":
				case ".com":
				case ".bat":
				case ".cmd":

Juan A. Ripoll - Programming Tutorials and Courses © 2024 All rights reserved.  Legal Conditions.