![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG_aE4GERihYadBPk660PBha4QtQPPcchC5kakXB23TjcqBH98vBpd6HmH_lqJOCqSSlnijUc43G6-paRa9FDj_KnZDIJW56s4Sv0e2KCT6z_ovJKPH6HHcEdnd4StnsY7v7XQOhYy9mI/s320/java+netbeans+programming+tutorial.jpg)
This simple code first checks if the Folder/Directory with the desired name exists or not. If there is no such Folder/Directory then the code will create one Folder/Directory with the name defined.
- File theDir = new File("New Folder"); // Defining Directory/Folder Name
- try{
- if (!theDir.exists()){ // Checks that Directory/Folder Doesn't Exists!
- boolean result = theDir.mkdir();
- if(result){
- JOptionPane.showMessageDialog(null, "New Folder created!");}
- }
- }catch(Exception e){
- JOptionPane.showMessageDialog(null, e);
- }
No comments:
Post a Comment