• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Vaild directory characters in Java?

I'm using the File object to query fileObj.isDirectory(mydir) and it's failing on a valid directory.  The directory in question is C:\files\c\temp\Downloads (0004)

Are spaces not allowed in java referenced directories?  Is it the paranthesis?  Are both bad?   Is there a way around this problem?  I'm referencing someone elses code that I don't have rights to recompile and he does a check with isDirectory.  I can't avoid that.  Is there any thing at all I can do?  Is there a list of valid dir characters so that I won't run into this problem again, if I merely need to avoid using some paths?  

I tested c:\files\c\temp\Downloads (I created this just to test) and that worked fine.  Any ideas?
1 Solution
It is working fine on me like this

File dir = new File("C:\\Downloads (0004)");

as suprapto45 shows it's a question of escaping the \ properly.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now