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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:59:52+00:00 2026-06-15T11:59:52+00:00

String sharedLocation = \\\\hostname new File(sharedLocation).list() returns null. exists() returns false as well. I

  • 0
String sharedLocation = "\\\\hostname"

new File(sharedLocation).list() returns null. exists() returns false as well. I do not know if this is something related to permissions. I am running the script on Windows.

Instead when I open via Windows -> Run and type in \\hostname, the shared folders are listed as a part of auto-complete in the Run window drop down. Why can’t I do the same with my java/groovy script? Is there a way to do this?

EDIT: Pardon the typo. The backslash was already escaped.

  • 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-15T11:59:53+00:00Added an answer on June 15, 2026 at 11:59 am

    The backslashes in your string resolve to \hostname. If you want to get \\hostname, you must have two backslashes and escape them properly

    String sharedLocation = "\\\\hostname"
    

    File is for existing files, but \\hostname is not a file or directory, but only a part of it. When you use \\hostname\share, you can list() all files in this share.

    For listing shares, you can look at this answer https://stackoverflow.com/a/8480995/1741542, which suggests using the The Java CIFS Client Library.

    With listRoots you can see already mounted shares.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

string tags = 9,3,12,43,2 List<int> TagIds = tags.Split(','); This doesn't work cause the split
String data=this we want append in that file; byte[] getbyte = data.getBytes(); outputstream.write(getbyte); outputstream.flush();
String sqlQueryToCreateUndergraduateDetailsTable = create table if not exists + TABLE_NAME_GPA + ( + BaseColumns._ID
String mimetype = .docx\tapplication/vnd.openxmlformats-officedocument.wordprocessingml.document; File file = new File(FilePath, filename); Intent intent = new
String myString=Plz_help; I came to know that 'myString' is not an object but a
String replacement in Python is not difficult, but I want to do something special:
String#to_i returns 0 when the string does not match any number characters, and I
string[] strArray = new string[10] { 21.65, 30.90, 20.42, 10.00, 14.87, 72.19, 36.00, 45.11,
String linkPattern = \\[[A-Za-z_0-9]+\\]; String text = [build]/directory/[something]/[build]/; RegExp reg = RegExp.compile(linkPattern,g); MatchResult matchResult
String html = Jsoup.connect(www.example.com).get().html(); Scanner in = new Scanner(html); String links ; while(in.hasNext()){ String

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.