Vanilla List Maling List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[VANILLA-L:1535] Java question



I thought I knew Java, I guess that is my first mistake :-(

I am writing some Java code for the Vanilla web site and I have run
into a problem.

Example code will explain it best.

import java.io.*;
import java.util.Vector;

public class MailingList {

  public static void main(String[] argv) {
    MailingList list = new MailingList("/usr/local/tmp/vanilla");
  }

  public MailingList(String pathname) {
    File parent  = new File(pathname);
    File[] years = parent.listFiles();

listFiles() returns an array of File objects, how can I find out the
number of elements in the array?

A similar problems with the lists() method, it returns an array of
Strings of files and directories in the abstract pathname.

So, how do I step through these arrays without getting an Exception by
accessing out of bounds on the array?

-- 
Bob Tanner <tanner@real-time.com>       | Phone : (612)943-8700
http://www.real-time.com                | Fax   : (612)943-8500
Key fingerprint =  6C E9 51 4F D5 3E 4C 66 62 A9 10 E5 35 85 39 D9 

+
++ Vanilla-l Mailing List ++
To unsubscribe: send "unsubscribe vanilla-l" to majordomo@real-time.com
For more information: http://archives.real-time.com