File Utility methods in liferay

Liferay has many utility method to handle the file like copyDirectory, copyFile, unZip, delete, createTmpfile etc..

In real scenerio to unzip the file we need to write pure java code but liferay has utility method to unzip the file

Have a look into the fileUtil class and look into the method unzip(File source, File destination)

public static void unzip(File source, File destination) {
PortalFilePermission.checkCopy(_getPath(source), _getPath(destination));
getFile().unzip(source, destination);
}

Also internally if we look into the how liferay is unzip, look into the ExpandTask class and look into the method as
public static void expand(File source, File destination) {
Expand expand = new Expand();
expand.setDest(destination);
expand.setProject(AntUtil.getProject());
expand.setSrc(source);
expand.execute();
}

Their it is using the Expand class(org.apache.tools.ant.taskdefs.Expand) of the lib ant.jar . Just with the 3 lines of code.

Comments

Popular posts from this blog

Theme display in javascript

How to know which liferay version we are using

Viewing the SQL Query in liferay : debugging the SQL Query in Hibernate