ContributionsMost RecentMost LikesSolutionssoap groovy copt file - inChannel.transferTo & Files.copy( I'm loosing my mind over this, every time I find some examples online that should work they either throw loads of messages or it just does not work. SOap 3.0 pro on Windows 10. I need to make a copy of an xlsx file to a path of my choosing. I click run, but nothing happens. No error msg, no log info. I'm fed up with groovy. private static void fileCopyUsingNIOChannelClass() throws IOException { File fileToCopy = new File("c:/temp/template.xlsx"); FileInputStream inputStream = new FileInputStream(fileToCopy); FileChannel inChannel = inputStream.getChannel(); File newFile = new File("c:/temp/template1.xlsx"); FileOutputStream outputStream = new FileOutputStream(newFile); FileChannel outChannel = outputStream.getChannel(); inChannel.transferTo(0, fileToCopy.length(), outChannel); inputStream.close(); outputStream.close(); } Also I tried this, smae **bleep**: Path source = Path.get("C:/temp/ISPC-OUTPUT.xlsx") Path destination = Path.get("C:/temp/ISPC-OUTPUT1.xlsx") Files.copy(source, destination); It's as if the program never compiles the code, but I get a blue star. SolvedRe: renameTo + tiimestamp A co worker just found this solution for me that works, I owe him :-) import groovy.io.FileType def now = new Date() def oldfile = new File("C:/temp/ISPC-OUTPUT.xlsx") String empty = "" oldfile.parentFile.eachFile (FileType.FILES) { file -> curDate = now.format("yyyyMMdd", TimeZone.getTimeZone('UTC')) String newName = file.path newName = newName.replaceAll(~/ISPC-OUTPUT/, "ISPC-OUTPUT"+"_"+curDate) file.renameTo newName log.info "New Name:- "+newName } renameTo + tiimestamp Hello everyone, I have this piece of groovy script that renames a file, this works fine as long as the name of the newfile doesn't change. However I wish to rename file = filename + timestamp (yyyy-mm-dd).xlsx . I have started creating a small timestamp to do this, however when I'm deperately trying to use this timestamp in my filename, but so far it does not work. Ny fiile is renamed java.text.SimpleDateFormat@69cbaae or Filename + Null or I get syntax errors. I'm using V3.0 pro and xlsx format. public class RenameFileJavaDemo { public static void main(String[] args) { //Old File File oldfile =new File("C:/temp/ISPC-OUTPUT.xlsx"); //New File // File newfile =new File("C:/temp/ISPC-OUTPUT_NEW1.xlsx"); File newfile =new File('C:/temp/ISPC-OUTPUT_NEW1' + '.xlsx'); Date date = new Date(); SimpleDateFormat df = new SimpleDateFormat("dd-M-yyyy a"); df.setTimeZone(TimeZone.getTimeZone("Europe/Oslo")); def datetime = df.format(date) /*renameTo() return boolean value * It return true if rename operation is * successful */ boolean flag = oldfile.renameTo(newfile); if(flag){ System.out.println("File renamed successfully"); }else{ System.out.println("Rename operation failed"); } } } Solved