My requirement is
using the 'zip' or 'tar' commands to generate the archive to standard output, and then streaming
that output back to server ( socket) where it can be fed to the standard input of another 'zip' or 'tar' command.
String[] cmd = { "/bin/sh", "-c", "cd /Users//jon//Documents//t1/; zip -r - ." };
ProcessBuilder builder = new ProcessBuilder(
cmd);
builder.redirectErrorStream(true);
Process p = builder.start();
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while (true) {
line = r.readLine();
if (line == null) {
break;
}
out.write(line.getBytes()); -- > I want to write this output data over socket and server should consume it and write it to zip file.
System.out.println(line);
}
question from:
https://stackoverflow.com/questions/65948910/zip-or-tar-commands-to-generate-the-archive-to-standard-output 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…