Results 1 to 6 of 6
- 05-10-2012, 02:48 AM #1
Member
- Join Date
- May 2012
- Posts
- 2
- Rep Power
- 0
Directory Listing Always giving Null on Windows 7
Hi Java Forums,
I'm a beginner programmer and was having an issue with some simple code. I am trying to get the list of files within a specific folder.
The code works perfectly on an existing Windows XP machine I tried, however on my Windows 7 PC it doesn't work and it always is null. I'm very confused because on both computers the Folder and files exists so as far as I can tell the only difference is the Operating System (And the version of Eclipse, but since this is such simply code I would assume it has nothing to do with Eclipse. The One returning null is running the Android ADK as well).
I'm wondering if Windows 7 has some security or something that blocks the Java (Using Eclipse) from seeing the directory? The user I'm logged in with has all access to the folder I'm looking at so I'm unsure why this is occurring.
The code is simply:
File dir = new File("C:\\Test\\");
String[] list = dir.list();
Windows XP - I receive a list array full of the documents
Windows 7 - I receive null
Any help would be appreciated, I have been messing around for a few days and can't figure it out sadly :( Thanks ahead of time.Last edited by Java_Newbie_1; 05-10-2012 at 02:50 AM.
- 05-10-2012, 02:58 AM #2
Re: Directory Listing Always giving Null on Windows 7
You could read the bug list to see if there are any known issues of your version of Java on Windows 7. You could also try using a single forward slash instead of the double backslash in the directory path.
- 05-10-2012, 03:49 AM #3
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: Directory Listing Always giving Null on Windows 7
When you don't have access it should throw a SecurityException exception. Are you sure that the path is exist on your C drive?
Website: Learn Java by Examples
- 05-10-2012, 03:55 AM #4
Re: Directory Listing Always giving Null on Windows 7
Check dir.exists() and dir.isDirectory()
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-10-2012, 02:29 PM #5
Member
- Join Date
- May 2012
- Posts
- 2
- Rep Power
- 0
Re: Directory Listing Always giving Null on Windows 7
Hey, thanks for the replies. Through a bit more troubleshooting I know its something to do with the android development and not java. I was able to get it working when it was a java project instead of an android project.
Not sure how familar people are with android app development here, but it has something to do with the android emulator or something.
Sorry about leading this in the wrong direction initially. I appreciate the help and ill try to research this problem more since I know a little more of the cause of the problem now. Thanks for the help. Hopefully it will be easier for me to research with this new information
- 05-10-2012, 04:30 PM #6
Similar Threads
-
listing files of directory and subdirectory
By oulutas in forum New To JavaReplies: 10Last Post: 10-10-2010, 05:48 PM -
Listing directory contents
By gandalf5166 in forum New To JavaReplies: 8Last Post: 05-02-2010, 12:41 AM -
JSP/Ajax/Post giving null values
By Mange in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 04-22-2010, 10:02 PM -
Recursively listing files in a directory accepted as a string??
By Zxcvtypo in forum New To JavaReplies: 8Last Post: 11-20-2009, 09:33 PM -
Listing file system from root directory
By Java Tip in forum Java TipReplies: 1Last Post: 04-18-2009, 10:03 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks