Returning the Root Drives

Returning the Root Drives

Can you tell me how to get the root drives on a system?

The 1.0 and 1.1 version of the Java APIs did not include a means ofdetermining the root drives or partitions on a system. During thedevelopment of the Swing APIs, it became clear such a function wasneeded to be able to implement the FileChooser class.Such a feature became available with the Swing 1.1 API in thejavax.swing.filechooser.FileSystemViewclass, which had a getRoots() method that returned an array ofFile instances corresponding to the root drives orpartitions. With the release of the Java 2 Platform, thisfunctionality was moved into the File class in the form of a staticgetRoots() method. The following simple program showshow to use either method to print out the available root file systems:

import*;import javax.swing.filechooser.*;public class ShowRootDrives {  public static final void printRoots(File[] roots) {    int file;    if(roots == null) {      System.err.println("Could not determine root partitions.
");      return;    }    for(file = 0; file < roots.length; ++file)      System.out.println(roots[file].toString());  }  public static final void main(String[] args) {    FileSystemView view;    // One way is to call File.listRoots() (only in JDK 1.2)    printRoots(File.listRoots());    // Another way is to use javax.swing.filechooser.FileSystemView    // (only in Swing 1.1 or JDK 1.2)    view  = FileSystemView.getFileSystemView();    printRoots(view.getRoots());  }}

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes