adsense


Showing posts with label JAVA EXAMPLES DISPLAY ROOT DIRECTORIES. Show all posts
Showing posts with label JAVA EXAMPLES DISPLAY ROOT DIRECTORIES. Show all posts

Wednesday, 28 October 2015

JAVA EXAMPLES DISPLAY ROOT DIRECTORIES PAGE 119

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



JAVA EXAMPLES DISPLAY ROOT DIRECTORIES





Java Examples - Display root directories


Problem Description:
How to display root directories in the system?
Solution:
Following example shows how to find root directories in your system using listRoots() method of File class.
import java.io.*;

class Main{
   public static void main(String[] args){
      File[] roots = File.listRoots();
      System.out.println("Root directories 
      in your system are:");
      for (int i=0; i < roots.length; i++) {
         System.out.println(roots[i].toString());
      }
   }
}

Result:
The above code sample will produce the following result. The result may vary depending on the system & operating system. If you are using Unix system you will get a single root '/'.
Root directories in your system are:
C:\
D:\
E:\
F:\
G:\
H:\


JAVA EXAMPLES DISPLAY ROOT DIRECTORIES PAGE 112

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



JAVA EXAMPLES DISPLAY ROOT DIRECTORIES






Java Examples - Display root directories



Problem Description:
How to display root directories in the system?
Solution:
Following example shows how to find root directories in your system using listRoots() method of File class.
import java.io.*;

class Main{
   public static void main(String[] args){
      File[] roots = File.listRoots();
      System.out.println("Root directories 
      in your system are:");
      for (int i=0; i < roots.length; i++) {
         System.out.println(roots[i].toString());
      }
   }
}

Result:
The above code sample will produce the following result. The result may vary depending on the system & operating system. If you are using Unix system you will get a single root '/'.
Root directories in your system are:
C:\
D:\
E:\
F:\
G:\
H:\