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 8079379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:04:57+00:00 2026-06-05T16:04:57+00:00

Following leads in this thread and others, I’ve set up a code block where

  • 0

Following leads in this thread and others, I’ve set up a code block where I map a network drive to a local drive and then I list some files inside it.

The problem is: it looks like the mapping is not available yet to the FileUtils method in the first call and, only if I wait and call the routine again, it finds the mapped drive ready to be used.

String path = "B:/Files/Somwething/SomethingElse/FinalDepth";
File newFile = new File("B:/Files/Something/SomethingElse");
if (!newFile.isDirectory()) {
    flagNetwork = true;
    p = Runtime.getRuntime().exec("net use B: " + networkSharedFolder);

    if(p != null) {
        Collection<File> files = FileUtils.listFiles(new File(path), arrExt, false);
        Iterator<File> iterFiles = files.iterator();
        while(iterFiles.hasNext()) {
            File tmpFile = (File) iterFiles.next();
            listResult.add(tmpFile);
        }
        LogServicio.doLog("[MyApplication, ContextListener] Drive B mapped to " + networkSharedFolder + ".", LogServicio.CErrorLvl);
    } else {
        throw new Exception("Error mapping network drive.");
    }
}

¿What should I do in order to use the mapped drive at once (or to guarantee that I waited until the drive is available)?

  • 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-06-05T16:04:58+00:00Added an answer on June 5, 2026 at 4:04 pm

    Runtime.exec starts a process running, but doesn’t really wait for it. You’d have to wait for the process to finish (via something like p.waitFor()) before you know the drive’s mapped.

    ...
    if (p != null) {
        while (true) {
            try { p.waitFor(); break; }
            catch (InterruptedException ex) { /* don't care */ }
        }
    
        Collection<File> files ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code loads html content from a file (i used this thread )
The following code leads to java.lang.IllegalThreadStateException: Thread already started when I called start() method
In C#, the following code (from this page) can be used to lazily instantiate
I have a following (simplified) code: var myModule = { submitDummyForm: function(){ console.log(this); //
I am following this article: http://www.lunametrics.com/blog/2011/12/01/automatic-cross-domain-tracking-revisited/ which leads me to put the following in
I have the following code that loads a user's Active Directory DirectoryEntry object from
I have the following code which loads and html file into a webview -
I am having issues with the following code which loads an SQLite database. -
In my ASP.NET application, a while down the stack I call the following code:
My Java program fails with the following error on Windows. Exception in thread main

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.