• Post Reply Bookmark Topic Watch Topic
  • New Topic

using zip in process

 
Lukas Okocim
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
i hava task and i must using linux command zip (not java.library zip or other )
in my program user send parameter path to the directory and program must zip all files in this subdirectory

so i write this command in linux:


and its work very god

but i have problem write it in java i use
String command = "find /user/test -type f -exec zip '{}'.zip '{}' \\:"
Process p = Runtime.getRuntime.exec(command)

but i have got error because cannot use exec in exec so i thing to use second type of function exec(command[], env[]);

but i donto know how write this function :/

i wrote something like this:


but its not working so please help how can i write this command in exec ???

thanks for any response

 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would advise you to read the following article: When Runtime.exec() won't
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the JavaRanch!
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lukasw lukaswasdf wrote:i wrote something like this:

Each argument to find should get its own array element, without the leading / trailing spaces:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!