Rename or move files

Here the source activity name is: Source_TextFile_Case1
The file is being renamed in the same folder where source file exists. It's been renamed by adding _conv in its file name.


try {

// filename of the file that need to be moved
String fileName = context.get("Service.Source_TextFile_Case1.fileName");
String fileName1 = null;
String fileExt = null;
// path of the directory where the file currently resides

String destDirPath = context.get("Service.Source_TextFile_Case1.filePath");
File f = new File(destDirPath + File.separatorChar + fileName);
fileName1 = fileName.substring(0, fileName.lastIndexOf("."));
fileExt = fileName.substring(fileName.lastIndexOf("."));
fileName = fileName1 + "_conv" + fileExt;
f.renameTo(new File(destDirPath + File.separatorChar + fileName));

catch (Exception e) {



Have more questions? Submit a request


Article is closed for comments.