I'm trying to run rsync command with runtime in java.
In my A.class file
@autowired
B bclass;
Public void testFileMove()
{
String srcPath="src/main/resources/tmp/"
String destPath="src/main/resources/destTemp"
ReflectionUtils.setField(bclass, "tempSrc", srcPath) ;
ReflectionUtils.setField(bclass, "tempDest", destPath) ;
bclass.execute();
}
String tempSrc;
String tempDest;
Public void execute()
{
String runtimeCmd= "rsync -avR --remove-source-files "+tempSrc+"/ "+tempDest
Process process =Runtime.getRunyime.exec(runtimeCmd) ;
Int exitCode=process.waitFor() ;
Logger.Info(" Exit code is :"+exitCode) ;
}
I need the path to be in resources folder of project so that its not specific to system path. With resources folder it become generic to project resource folder and this helps my build in bamboo as well.