This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I'm trying to make a list, set, map, (alright, I really don't care what it's called, as long as it works! ) of all of the directories and files on my hard drives.
I've started writing code. Found some on a website, and have tried to implement it. Here's the problem. Array, Vector, and HashSet all to up to int size, or 32,000 + entries. My problem is that I currently have over 100,000 files on one drive alone.
To be fair, I've only compiled it. Haven't run it yet. I'm not sure how many bugs in it! However, at this point, I'm more concerned with how to get a real list of the complete file names including drive, sub-directory, and file names.
None of these classes have any practical size limits. There are theoretical limits near 2 billion entries, but since no existing JVM can support a large enough heap to exceed this, it's not of practical concern (and disk drives that can contain more than 2 billion entries are still rather rare as well, and no flavor of Windows would support one that did.)
Where did you get that 32,000 number? That's the maximum positive value of a signed 16-bit int, but Java ints are 32 bits.
Don't use Vector in new code; it's a legacy class that's been superceded by ArrayList.
Finally: so tell us why you want to do this, anyway? What is the list for? Why make a list rather than simply visiting each file in order without storing the paths?
Oops, I mis-thought. I did know that a short is 16 and an int is 32 bits. I guess I needed a kick in the britches!
A couple of days ago I posted a query in this forum, asking whether anyone was interested in helping even define the requirements, but got no takers. Here's what I'm trying to do:
I'd like to create a simple client / server app that takes each file from the client machine, runs it through a "ZipOutputStream", serializes and sends it out to a second machine via IP to make a compressed backup of each individual file (in the correct directory tree) at least once a day, however, possibly multiple times a day.
I know that this is very simplified, however, I have someone who would actually like to try to do his backups off-site, and I thought I could "cut my teet" on a project of this size.
We may or may not have to make a GUI to deal with backup and restore options, features, etc. This can be discussed in a group forum.
I'd be delighted to do a full open-source project and leave it here on javaRanch.com for others.
As for the question of why I wanted to make an array, I was just trying to see what kind of challenges I'm going to run into when I do start building.
Any takers for this kind of project? I think it would be kind of fun! If so, where on the ranch would be the right place to start this kind of project? Is there a barn, or do we have to go out to the forest!?