Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java Language
Expertise: Beginner
Apr 5, 1999

Array Length

Question:
How do I know the size of the array returned by File.list() so I don't get the message ArrayIndexOutOfBoundsException when printing the local directory content in the screen?

Answer:
All arrays have an intrinsic member variable called length. To get the list length you would do the following:

File list;

list = directory.list();
System.out.println("Numbr of Files is: " + list.length);
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date