Finding a File?
Author |
Message |
Krocker
|
Posted: Mon Dec 19, 2011 10:42 am Post subject: Finding a File? |
|
|
hey guys, i was wondering, is it possible to create a java program which will find specific files and/or folders and delete them? i wanted to make a cleaner software that a user can choose what files/folders they want to delet form a list and the program will delete these files and folders. is it also possilble to find the files if they are a hidden file? either way, how would i do it? Also im using RTP so ya. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
DemonWasp
|
Posted: Mon Dec 19, 2011 11:17 am Post subject: RE:Finding a File? |
|
|
You'd have to use the File class (look here: http://docs.oracle.com/javase/1.4.2/docs/api/java/io/File.html ). Be careful, though, because some operating systems (cough, Windows) will let you delete system-critical files (such as boot.ini) instantly, with no easy way to fix the problem.
In general, you will have to have write access to a file to delete it, and you will not be able to delete it while the file is locked (usually by another process accessing it). Check the return value of delete() to figure out whether you actually deleted the thing you were hoping to delete.
You will also have to recursively delete files within a folder yourself before deleting the folder (note that the delete() method says it will only delete empty folders). |
|
|
|
|
 |
Krocker
|
Posted: Mon Dec 19, 2011 12:38 pm Post subject: RE:Finding a File? |
|
|
SRRY, BUT THAT REALLY DIDNT HELP ME CUZ I DONT KNOW HOW TO USE THEM. |
|
|
|
|
 |
DemonWasp
|
|
|
|
 |
|
|