Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 992025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:12:01+00:00 2026-05-16T06:12:01+00:00

i have to write the code using simple java.i have to copy one source

  • 0

i have to write the code using simple java.i have to copy one source file to the destination file.the problem is that the user have to select the source and destination from any drives available.how to call the available drives in the java .no need of buttons
thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:12:02+00:00Added an answer on May 16, 2026 at 6:12 am

    java.io.File has a static utility method listRoots() that returns a File[] of available filesystem roots.

    From the documentation:

    A particular Java platform may support zero or more hierarchically-organized file systems. Each file system has a root directory from which all other files in that file system can be reached. Windows platforms, for example, have a root directory for each active drive; UNIX platforms have a single root directory, namely "/". The set of available filesystem roots is affected by various system-level operations such as the insertion or ejection of removable media and the disconnecting or unmounting of physical or virtual disk drives.

    Here’s an example snippet:

        import java.io.*;
    
        //...
        for (File root : File.listRoots()) {
            System.out.println(root.getAbsolutePath());
            System.out.println(root.getTotalSpace());
        }
    

    This prints the absolute path and total space of each of the system’s filesystem root.

    Related questions

    • Find all drive letters in Java
    • Acquiring drive names (as opposed to drive letters) in Java

    Swing GUI component

    If you are using Swing for GUI, there’s javax.swing.JFileChooser which you may be able to use. It’s highly customizable (e.g. file extension filtering), and you can use it to select files and/or directories for saving and/or loading.

    See also

    • The Swing Tutorial – Components – How to use File Choosers

    Related questions

    • Save using JFileChooser with pre-populated file name?
    • JFileChooser.showSaveDialog(…) – how to set suggested file name
    • adjust selected File to FileFilter in a JFileChooser
    • How do I restrict JFileChooser to a directory?
    • Alternative to JFileChooser
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far I have managed to write some code that should print the source
I have a bit of Java code that outputs an XML file to a
I usually write java code using a simple text editor and .bat files to
I want to write a Java code, which will send a simple text file
I have this strange problem. I'm trying to write a simple Hello World java
I have implemented simple proxy server using Java NIO channels, but have a problem,
I currently using android NDK to write some native code in C. I have
Sometimes I have to write code that alternates between doing things and checking for
I have been trying to write some code in Scala to read a file
I have a text editor in which a user can write HTML code. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.