Computer Science Canada

Java File Search

Author:  Argon [ Fri Mar 10, 2006 11:08 pm ]
Post subject:  Java File Search

Can someone show me how to make a java program that can do much the same thing as the windows file search? New to Java so its probably easy and i just don't know how...so can someone plz guide me in the right direction

Author:  wtd [ Fri Mar 10, 2006 11:19 pm ]
Post subject: 

If you're new to Java then that's over your head, and trying to tackle it is going to leave you very frustrated. Simpler programs will give you an understanding of the language, and then you can try more complex stuff.

"Hello world!" seems stupid and pointless, but there's a reason for it.

Author:  1of42 [ Sat Mar 11, 2006 1:29 am ]
Post subject: 

I actually did something like that, but for a slightly different reason... anyways, if you're new to Java, then it's not the best idea. The method I used involves a function that, when given a starting directory, lists the cotnents of the directory, and for each subdirectory, recursively calls itself with the subdirectory as the argument, with each level of the function returning an ArrayList comprising the matches from each subdirectory beyond that.

The File class is the one necessary for the actual work.

Author:  Argon [ Sun Mar 12, 2006 9:29 pm ]
Post subject: 

well when I said "new" I meant I've been learning Java for about a year so I can probably understand it

Author:  wtd [ Sun Mar 12, 2006 10:08 pm ]
Post subject: 

Tell us how you would break this problem down, without writing any code.

Author:  Justin_ [ Mon Mar 13, 2006 12:05 am ]
Post subject: 

A year? lol, I'm not sure that's qualified as new, especially if you've only been learning java... you should be pretty intermediate after a year. Take me for example, I thought programming was for rocket scientists up until Sept. of last year when I was introduced to Turing. I've learned a fair deal about programming in 6 months time, especially considering that I had no background in coding whatsoever. Given another 6 months I know I could put together a file search program in a week, at least in C++ anyway. Right now it would probably take me 3 weeks to do it. But the point is once you have the knowledge about how programming is done, you can easily do the research to see what is out there to aid you. Aid would come in the form of libraries and specific classes that would help you a great deal... And then once you understand what classes you'll need and how to use them you just start putting things together... Simple, really, especially if you've been learning the language for a year.

Author:  Argon [ Wed Mar 15, 2006 4:01 pm ]
Post subject: 

I finished doing turning...I did 2 years of it...I did the file search thing with turing and I want to know how to do it with Java

Author:  wtd [ Wed Mar 15, 2006 4:03 pm ]
Post subject: 

Argon wrote:
I finished doing turning...I did 2 years of it...I did the file search thing with turing and I want to know how to do it with Java


Well, tell us how you'd break the problem down without writing any code. Once you do that, you can ask very specific questions. Smile

Author:  Argon [ Thu Mar 16, 2006 1:19 pm ]
Post subject: 

well here goes....

1. ask for search criteria
2. ask where to search
3. search root folder for file matching criteria

loop until all files in root folder have been checked

if a match is found store in matchfound array
if not skip the file

4. Are there subfolders?

If there are list them alphabetically

assign a number to each folder in the list instead of an array to save memory.

5. go to subfolder and repeat steps 3 and 4

6. once all directories have been searched display the matchfound array

7. using GUI if user clicks on a file display properties, a copy link and a "view containing folder" option

I would also add a save search log but that i can do on my own

Author:  Justin_ [ Thu Mar 16, 2006 1:23 pm ]
Post subject: 

So what are you waiting for Argon? Begin with step one, make that portion of your program and then procede to step two, until you get stuck with some specific problems and post your code here for some help...

Author:  wtd [ Thu Mar 16, 2006 1:24 pm ]
Post subject: 

Argon wrote:
if a match is found store in matchfound array


This is code. Wink

Author:  Argon [ Thu Mar 16, 2006 1:25 pm ]
Post subject: 

oh also when I assign a number I'll use a counter to move down the list...if I am not clear on anything just tell me outright it won't bother me

Author:  Argon [ Thu Mar 16, 2006 1:26 pm ]
Post subject: 

yah I know it's code but sometimes it's easier that way istead of explaining it in English if you know what I mean Laughing

Author:  Justin_ [ Thu Mar 16, 2006 1:31 pm ]
Post subject: 

Argon do you expect one of us to write a tutorial for you?

Author:  wtd [ Thu Mar 16, 2006 1:37 pm ]
Post subject: 

Argon wrote:
yah I know it's code but sometimes it's easier that way istead of explaining it in English if you know what I mean Laughing


What I'm trying to get you to see is what you want to accomplish, rather than how to accomplish it. The problem-solving process should always start with a thorough understanding of the problem.


: