View Full Version: Creating a File Manager program

C++ Learning Community > Other Programing Languages > Creating a File Manager program


Title: Creating a File Manager program
Description: in Java


Sparkle1984 - January 6, 2004 05:35 PM (GMT)
I would like to create a freeware Java tool (with a graphical user interface) which will be able to scan a specific directory which is specified by the user, at a certain time interval (eg once every 5 minutes) and look at the endings of all the files, and move them to a different directory, depending on their type. For example, a file ending with .PDF could be moved into a directory called Documents, and a file ending with .exe or .zip could be moved into a directory called Software.

The aim is to enable people to organise their media files effectively. :)

I was just wondering how I would go about it, eg what Java classes would I need to use?

Thanks for any advice.


FrozenKnight - January 6, 2004 08:27 PM (GMT)
well i know how to do this with c++, and maybe asm but not java. First you get a directory listing scan the extensions then use the OS's move command to move the files.

Btw I’d move Zips in to a folder for compressed files because zips can have more than just programs.

THE Wizard Genius - January 19, 2004 01:01 AM (GMT)
In my opinion, this is a very advanced project. Unless you know how even to OPEN a file or COPY or MOVE a file in Java, better learn more first (Not that I KNOW Java myself; I'm just telling you from experience) ;)

Of course, if you do ever pull it off, I would be happy to beta test it for you. Do you have a website? Or a Net "Company"? If you need a Net "Company" to join, join mine! go to The QBSpot or e-mail me at WizardGenius2001@yahoo.com

OK? Alright? Contact me? Thx and good luck! ^_^

Incubator - January 21, 2004 10:13 PM (GMT)
a file manager isnt that much of an advanced project :P

anywhay, opening files in Java isnt that hard.

import java.io.File;

File myfile = new File("file.txt");

you might want to use javax.swing.*; and javax.swing.events.*;
for the gui.
It would have a JFrame that contains a JPanel. This main panel contains if needed other JPanels.
The required controls are JTextField, JList (or was it JListView, cant remember)
JButton

look in the javadcc if there is a timer, I believe so though, just order it to wait 5000 ms to execute your function to fill teh list again.

to iterate checkDir(mElements[i]); //mElements is just a String[]through dirs:
CODE

public void checkDir(String dir) {
    File dir = new File("/"'); //root dir, new File(".") for current dir

the Dir class has a method that returns an array os strings with its elements.
Once again my memory fails me for the name, check javadoc or jbuilder/intelliJ

   for (int i = 0; i<mElements.length(); i++) {
    //    check if it is a dir or file. this is something I still dont know yet in java
     //if dir, insert item with a folder icon, else with a regular icon
   }

check javadoc for the exact method to insert items in your listview


derive a class from ItemListener and add it to the list.
The itemListener should handle the event that when you selected a file, (if needed) some proerties are loaded, and that you can do stuff with it




* Hosted for free by InvisionFree