473,394 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Why File.listFiles() prints Directories?

Hi, According to J2SE API documentation, The description of the methods list() and listFiles() is as followes:
String[] list()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
File[] listFiles()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.

But the listFiles() method is displaying directories too and I dont understand why. I tried the same program on UNIX platform too. There is no separate method which will display just the Directories or Folders.
Thanks in advance.
Oct 10 '07 #1
3 1683
dmjpro
2,476 2GB
Hi, According to J2SE API documentation, The description of the methods list() and listFiles() is as followes:
String[] list()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
File[] listFiles()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.

But the listFiles() method is displaying directories too and I dont understand why. I tried the same program on UNIX platform too. There is no separate method which will display just the Directories or Folders.
Thanks in advance.
Have a look at this and also this

Debasis Jana.
Oct 11 '07 #2
JosAH
11,448 Expert 8TB
But the listFiles() method is displaying directories too and I dont understand why. I tried the same program on UNIX platform too. There is no separate method which will display just the Directories or Folders.
Thanks in advance.
Would you understand the functionality if the methods were named 'listEntries'?
Both methods simply list all entries given an entry (read: File). One returns
Strings, the names of the entries and the other returns the entries themselves.

You can interrogate each entry for representing a directory or a regular file entry.

kind regards,

Jos
Oct 11 '07 #3
Have a look at this and also this

Debasis Jana.
Thank you for pointing me to File Filters. I didnt realise filters would solve what I am trying to achieve.
Regards,
eh
(Please close this forum)
Oct 12 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: David | last post by:
Because of limitations of my provider, I am forced to use the ftp functions to upload files to my server (the permissions on the server will not allow me to load files via php). I have...
4
by: Ruby Tuesday | last post by:
Is there a fast way to read files/directory recursively? Instead of inspecting each file(s)/dir(s), is there a way to know that its a file or a directory from its hidden attribut both for windows...
1
by: Joel Goldstick | last post by:
I wanted to write a simple page to let me choose a directory and then list the files in it. The end goal was to make an easy way to copy all the file names in a directory. I tested with Opera7,...
7
by: Anbu | last post by:
Hi, I want to load contents of a remote HTML file and to display it on the ASP ..NET Web Page. The remote HTML file is not under any virtual folder and the content & location may vary for each...
4
by: lcifers | last post by:
Is there a way, through VB.NET, to determine if the user has selected this option? I am writing an application that does some string functions to rename files, and the file names get chopped up if...
0
by: shiloha | last post by:
Hello! How can I execute a batch file that calls a script? I got an error that says: Fatal: Unable to open myscript.src This is the code (i copied) :) ...
5
by: Krustov | last post by:
I have the following list of image files . When searching the latest (numbered file) in this particular case its background_4.*** and its a .jpg file - but - the latest file in the list could...
10
by: deciacco | last post by:
I'm writing a command line utility to move some files. I'm dealing with thousands of files and I was wondering if anyone had any suggestions. This is what I have currently: $arrayVirtualFile =...
2
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.