Display directory Java Exercise - Java Programming Course

 Exercise

Display directory

 Objetive

Create a program that shows the files in the current folder.

 Example Code

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

		for (String file : files)
		{
			System.out.println(file);
		}
	}
}

More Java Exercises of Additional Libraries

 Date and time
Create a program to display the current date and time with the following format: Today is 6 of February of 2015. It´s 03:23:12...
 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....
 Date and time continuous
Create a program that shows the current time in the top-right corner of the screen with the format: 12:52:03 The program should pause for one se...
 Sitemap creator
A "sitemap" is a file that webmasters can use to inform Google about the webpages that their website includes, with the aim of achieving better search...
 List of images as HTML
Create a program that creates an HTML file that lists all the images (PNG and JPG) in the current folder. For instance, if the current folder conta...
 System information
Create a program that shows specific system details, including the computer name, domain name, and the username of the user who is currently logged in...
 Sitemap creator v2
You need to create a program that takes the following parameters: the name of a text file containing the URLs, the modification date, and the change f...
 Surf directory
Create a program that displays the files in the current folder and allows the user to move up and down the list. If the user presses Enter on a folder...
 Subdirectories
Create a program to store the files that are located in a particular folder and its subfolders. Then, it will ask the user which text to search and...


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