[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Vaild directory characters in Java?

Posted on 2006-05-25
4
Medium Priority
?
202 Views
Last Modified: 2010-04-17
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?
0
Comment
Question by:nolij
2 Comments
 
LVL 16

Accepted Solution

by:
suprapto45 earned 2000 total points
ID: 16766212
It is working fine on me like this

File dir = new File("C:\\Downloads (0004)");
System.out.println(dir.isDirectory());

David
0
 
LVL 24

Expert Comment

by:fridom
ID: 16766443
as suprapto45 shows it's a question of escaping the \ properly.

Regards
Friedrich
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Loops Section Overview

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question