public static boolean createNewLockFile(String filePath,FileType fileType) throws IOException {
  filePath=filePath.replace("\\","/");
switch (fileType) {
case HDFS:
case VIEWFS:
    Path path=new Path(filePath);
  FileSystem fs=path.getFileSystem(configuration);
if (fs.createNewFile(path)) {
  fs.deleteOnExit(path);
  return true;
}
return false;
case LOCAL:
default :
File file=new File(filePath);
return file.createNewFile();
}
}

public static boolean createNewLockFile ( String filePath , FileType fileType ) throws IOException { filePath = filePath . replace ( "\\" , "/" ) ; switch ( fileType ) { case HDFS : case VIEWFS : Path path = new Path ( filePath ) ; FileSystem fs = path . getFileSystem ( configuration ) ; if ( fs . createNewFile ( path ) ) { fs . deleteOnExit ( path ) ; return true ; } return false ; case LOCAL : default : File file = new File ( filePath ) ; return file . createNewFile ( ) ; } }
for creating a new lock file and if it is successfully created then in case of abrupt shutdown then the stream to that file will be closed .
