public void ReadFully(byte[] b, int off, int len) { if (len == 0) return; int n = 0; do { int count = Read(b, off + n, len - n); if (count <= 0) throw new EndOfStreamException(); n += count; } while (n < len); }
/* public static void Main(String[] args) { * try { * RandomAccessFileOrArray inp = new RandomAccessFileOrArray(args[0]); * Stream outp = new FileOutputStream(args[1]); * Convert(inp, outp); * inp.Close(); * outp.Close(); * } * catch (Exception e) { * e.PrintStackTrace(); * } * }*/ private String ReadString(int n) { byte[] b = new byte[n]; inp.ReadFully(b); int k; for (k = 0; k < b.Length; ++k) { if (b[k] == 0) { break; } } return(encoding.GetString(b, 0, k)); }