static void compress(FrequencyTable freq, InputStream in, BitOutputStream out) throws IOException {
		ArithmeticEncoder enc = new ArithmeticEncoder(out);
		// int count = 0;
		while (true) {
			int b = in.read();
			if (b == -1)
				break;
			// System.out.print("\r"+(++count));
			enc.write(freq, b);

		}
		// System.out.print("\n");
		enc.write(freq, 2);  // EOF
		enc.finish();
	}