java2db

How to delete a file or folder from directory in java



Use a method called delete() from  java.io.File to  delete a file. While doing this operation , we need to take care about the parent path name and the file name.

 

delete a file or folder from directory in java It returns true if the file or directory deleted successfully , otherwise it returns false.
delete a file or folder from directory in java It throws an IOException when a file or directory does not exist in the specified location .

 

Syntax:

boolean <BooleanObjName> = <FileObject>.delete();

Example to delete a file :

Execution Result:

delete a file or folder from directory in java If the specified directory having files, This method should not  delete the directory.




Related Posts :
How to Connect to Oracle from Liferay portlet ( Java Liferay and Oracle integration )
How to Connect Liferay 7 to PostgreSQL ( Java Liferay portlet and PostgreSQL integration )
How to call C# .Net WCF web service in java SOAP client ( Visual Studio 2013 )
How to call PHP RESTful web service in java client
How to call java SOAP web service in php ( php web service client )
Solution to SSLHandshakeException (skip the certificate for Java and LDAP bind)
Java RESTful web service example in maven using JAX-RS
RESTful web service example in java using JAX-RS
   [will not be published]



^ <