Java | Print root directories Last Updated : 24 Mar, 2018 Comments Improve Suggest changes Like Article Like Report In Java we can use listRoots() of File class to find all root directories. Java import java.io.*; public class GeeksforGeeks { public static void main(String[] args) { File[] rDirs = File.listRoots(); for (int i = 0; i < rDirs.length; i++) System.out.println(rDirs[i].toString()); } } Output (In Windows with two drives) C:\ D:\ Output (In Linux) / Comment More infoAdvertise with us Next Article Java | Print root directories GeeksforGeeks Improve Article Tags : Java Practice Tags : Java Similar Reads Traversing directory in Java using BFS Given a directory, print all files and folders present in directory tree rooted with given directory. We can iteratively traverse directory in BFS using below steps. We create an empty queue and we first enqueue given directory path. We run a loop while queue is not empty. We dequeue an item from qu 2 min read How to Check a File or Directory Exists in Java? One of the most frequent tasks carried out by a file system in an operating system is checking the existence of a directory or a file. In the form of library functions, most programming languages provide some level of file system accessibility. You will discover how to test an existing file or direc 1 min read How to Scan All Mp3 Files In the Given Directory using Java? In this article, we will discuss how to scan all mp3 files and not only from a specific path for an android media player. We will use a recursive method for scanning files. Scan all folders and sort out all mp3 files using the File and FileFilter class. ImplementationJava import java.io.File; import 1 min read Files createTempDirectory() Method in Java with Examples The createTempDirectory() method of java.nio.file.Files Class is used to create a new directory using the given prefix and attributes. The given prefix acts as the name of the formed directory, may be null. The directory is set with given attributes. Based on the type of arguments passed, the Files 4 min read How to find and open the Hidden files in a Directory using Java Pre-requisites: Java File Handling So far the operations using Java programs are done on a prompt/terminal which is not stored anywhere. But in the software industry, most of the programs are written to store the information fetched from the program. One such way is to store the fetched information 3 min read Like