iTextSharp.text.io.StreamUtil.InputStreamToArray C# (CSharp) Метод

InputStreamToArray() публичный статический Метод

public static InputStreamToArray ( Stream inp ) : byte[]
inp Stream
Результат byte[]
        public static byte[] InputStreamToArray(Stream inp) {
            byte[] b = new byte[8192];
            MemoryStream outp = new MemoryStream();
            while (true) {
                int read = inp.Read(b, 0, b.Length);
                if (read < 1)
                    break;
                outp.Write(b, 0, read);
            }
            outp.Close();
            return outp.ToArray();
        }
        

Usage Example

Пример #1
0
 /**
  * Creates a new {@link RandomAccessSource} by reading the specified file/resource into memory
  * @param filename the name of the resource to read
  * @return the newly created {@link RandomAccessSource}
  * @throws IOException if reading the underling file or stream fails
  */
 private IRandomAccessSource CreateByReadingToMemory(Stream inp) {
     try {
         return new ArrayRandomAccessSource(StreamUtil.InputStreamToArray(inp));
     }
     finally {
         try {inp.Close();}catch{}
     }
 }
All Usage Examples Of iTextSharp.text.io.StreamUtil::InputStreamToArray