Hi all,


I would like to know whether there any JAVA API exists which does copying, deleting or moving files from and to directories and which is platform independent.

I mean consider 3 layers. Last one is of OS (windows, linux, unix, solaris). Middle one is of JAVA API and top most is of application. In the application user will give copy command java api would treat that command in accordance with OS. Has anyone worked on such API? Does anyone know about this? I would like to know more about this. I tried to google on this and I was not able to get much.

Thank you very much.


Abhijit.

Yeah, File. You read it and write it to copy, you listFiles to list them, and you use delete to delete them. Where's the problem?

Yeah, File. You read it and write it to copy, you listFiles to list them, and you use delete to delete them. Where's the problem?

Hi,


I want to do like this.

if (os==windows)
classname.runCommand(windows commands)
else if (os==linux)
classname.runcommand(linux command)


something like this. I have been learning java from such short modules or programmes. I want a reference to study such sort of application. If I am stuck, I want a guidance from such API. That is why I am asking whether anyone knows about this or anyone has worked out on this. Thank you very much for your suggestions.


Regards.

There is no API, AFAIK, for that. That is not the sort of thing you want to be doing anyway. Runtime.exec and ProcessBuilder are, IMHO, tools of last resort and should not be the preferred execution path.

What masijade was trying to say is to look at: class File from the Java API.
It's better to do that instead of:

if (os==windows)
classname.runCommand(windows commands)
else if (os==linux)
classname.runcommand(linux command)

If you want to make system dependent "command" calls, look at the class ProcessBuilder.

This article has been dead for over six months. Start a new discussion instead.