Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
240 views
in Technique[技术] by (71.8m points)

zip' or 'tar' commands to generate the archive to standard output

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...