
-----------------------------------
Argon
Fri Mar 10, 2006 11:08 pm

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

-----------------------------------
wtd
Fri Mar 10, 2006 11:19 pm


-----------------------------------
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.

-----------------------------------
1of42
Sat Mar 11, 2006 1:29 am


-----------------------------------
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.

-----------------------------------
Argon
Sun Mar 12, 2006 9:29 pm


-----------------------------------
well when I said "new" I meant I've been learning Java for about a year so I can probably understand it

-----------------------------------
wtd
Sun Mar 12, 2006 10:08 pm


-----------------------------------
Tell us how you would break this problem down, without writing any code.

-----------------------------------
Justin_
Mon Mar 13, 2006 12:05 am


-----------------------------------
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.

-----------------------------------
Argon
Wed Mar 15, 2006 4:01 pm


-----------------------------------
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

-----------------------------------
wtd
Wed Mar 15, 2006 4:03 pm


-----------------------------------
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.  :)

-----------------------------------
Argon
Thu Mar 16, 2006 1:19 pm


-----------------------------------
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

-----------------------------------
Justin_
Thu Mar 16, 2006 1:23 pm


-----------------------------------
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...

-----------------------------------
wtd
Thu Mar 16, 2006 1:24 pm


-----------------------------------
if a match is found store in matchfound array

This is code.  ;)

-----------------------------------
Argon
Thu Mar 16, 2006 1:25 pm


-----------------------------------
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

-----------------------------------
Argon
Thu Mar 16, 2006 1:26 pm


-----------------------------------
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  :lol:

-----------------------------------
Justin_
Thu Mar 16, 2006 1:31 pm


-----------------------------------
Argon do you expect one of us to write a tutorial for you?

-----------------------------------
wtd
Thu Mar 16, 2006 1:37 pm


-----------------------------------
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  :lol:

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.
