Link to home
Start Free TrialLog in
Avatar of srikotesh
srikotesh

asked on

Alternative approach for file copying instead of Runtime.exec method

Hi Experts,

Runtime rt = Runtime.getRuntime();
Process p = rt.exec("cp " +sourceFile+" "+destFile);

Open in new window


is there any specic reason using the above code or it is legacy code.
can i use alternative approach as below or any better approach is there for file copying

Files.copy(source.toPath(), dest.toPath());

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of dpearson
dpearson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of srikotesh
srikotesh

ASKER

thanks