private static boolean readFully(InputStream in, byte[] buf) throws IOException {
		int len = buf.length;
		int pos = 0;
		while (pos < len) {
			int read = in.read(buf, pos, len - pos);
			if (read == -1) {
				return true;
			}
			pos += read;
		}
		return false;
	}