2015-09-29 12:04:07 -07:00
|
|
|
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
|
2015-10-28 11:20:59 -07:00
|
|
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
|
|
|
|
|
|
// See page 365.
|
|
|
|
|
2015-09-29 12:04:07 -07:00
|
|
|
//!+
|
|
|
|
|
|
|
|
// Bzipper reads input, bzip2-compresses it, and writes it out.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"gopl.io/ch13/bzip"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
w := bzip.NewWriter(os.Stdout)
|
|
|
|
if _, err := io.Copy(w, os.Stdin); err != nil {
|
|
|
|
log.Fatalf("bzipper: %v\n", err)
|
|
|
|
}
|
|
|
|
if err := w.Close(); err != nil {
|
|
|
|
log.Fatalf("bzipper: close: %v\n", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//!-
|