jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
/* ====================================================================
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
==================================================================== */
 
/* ================================================================
 * About NPOI
 * Author: Tony Qu 
 * Author's email: tonyqus (at) gmail.com 
 * Author's Blog: tonyqus.wordpress.com.cn (wp.tonyqus.cn)
 * HomePage: http://www.codeplex.com/npoi
 * Contributors:
 * 
 * Revision
 * Who          Date            Comment  
 * Tony Qu      2008.10.18      add methods to support ulong
 * ==============================================================*/
 
using System;
using System.IO;
 
namespace HH.WMS.Utils.NPOI.Util
{
    /// <summary>
    /// a utility class for handling little-endian numbers, which the 80x86 world is
    /// replete with. The methods are all static, and input/output is from/to byte
    /// arrays, or from InputStreams.
    /// </summary>
    /// <remarks>
    /// @author     Marc Johnson (mjohnson at apache dot org)
    /// @author     Andrew Oliver (acoliver at apache dot org)
    /// </remarks>
    public class LittleEndian : LittleEndianConsts
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="LittleEndian"/> class.
        /// </summary>
        private LittleEndian()
        {
            // no instances of this class
        }
 
        /// <summary>
        /// get a short value from a byte array
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <returns>the short (16-bit) value</returns>
        public static short GetShort(byte[] data, int offset)
        {
            int b0 = data[offset] & 0xFF;
            int b1 = data[offset + 1] & 0xFF;
            return (short)((b1 << 8) + (b0 << 0));
            //return (short)GetNumber(data, offset, LittleEndianConsts.SHORT_SIZE);
        }
 
        /// <summary>
        /// get an unsigned short value from a byte array
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <returns>the unsigned short (16-bit) value in an integer</returns>
        public static int GetUShort(byte[] data, int offset)
        {
            //short num = (short)GetNumber(data, offset, LittleEndianConsts.SHORT_SIZE);
            //if (num < 0)
            //{
            //    return (ushort)(0x10000 + num);
            //}
            //return (ushort)num;
            int b0 = data[offset] & 0xFF;
            int b1 = data[offset + 1] & 0xFF;
            return (b1 << 8) + (b0 << 0);
        }
 
        /// <summary>
        /// get a short value from a byte array
        /// </summary>
        /// <param name="data">a starting offset into the byte array</param>
        /// <returns>the short (16-bit) value</returns>
        public static short GetShort(byte[] data)
        {
            return GetShort(data, 0);
        }
 
        /// <summary>
        /// get a short value from a byte array
        /// </summary>
        /// <param name="data">the unsigned short (16-bit) value in an integer</param>
        /// <returns></returns>
        public static int GetUShort(byte[] data)
        {
            return GetUShort(data, 0);
        }
 
        /// <summary>
        /// get an int value from a byte array
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <returns>the int (32-bit) value</returns>
        public static int GetInt(byte[] data, int offset)
        {
            //return (int)GetNumber(data, offset, LittleEndianConsts.INT_SIZE);
            int i = offset;
            int b0 = data[i++] & 0xFF;
            int b1 = data[i++] & 0xFF;
            int b2 = data[i++] & 0xFF;
            int b3 = data[i++] & 0xFF;
            return (b3 << 24) + (b2 << 16) + (b1 << 8) + (b0 << 0);
        }
 
        /// <summary>
        /// get an int value from the beginning of a byte array
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <returns>the int (32-bit) value</returns>
        public static int GetInt(byte[] data)
        {
            return GetInt(data, 0);
        }
 
        /// <summary>
        /// Gets the U int.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <returns>the unsigned int (32-bit) value in a long</returns>
        public static long GetUInt(byte[] data, int offset)
        {
            //uint num = (uint)GetNumber(data, offset, LittleEndianConsts.INT_SIZE);
            //if (num < 0)
            //{
            //    return (uint)(0x100000000L + num);
            //}
            //return num;
            long retNum = GetInt(data, offset);
            return retNum & 0x00FFFFFFFFL;
        }
 
        /// <summary>
        /// Gets the U int.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <returns>the unsigned int (32-bit) value in a long</returns>
        public static long GetUInt(byte[] data)
        {
            return GetUInt(data, 0);
        }
 
        /// <summary>
        /// get a long value from a byte array
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <returns>the long (64-bit) value</returns>
        public static long GetLong(byte[] data, int offset)
        {
            //return GetNumber(data, offset, LittleEndianConsts.LONG_SIZE);
            long result = 0;
 
            for (int j = offset + LONG_SIZE - 1; j >= offset; j--)
            {
                result <<= 8;
                result |= 0xffL & data[j];
            }
            return result;
        }
 
        /// <summary>
        /// get a double value from a byte array, reads it in little endian format
        /// then converts the resulting revolting IEEE 754 (curse them) floating
        /// point number to a c# double
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <returns>the double (64-bit) value</returns>
        public static double GetDouble(byte[] data, int offset)
        {
            return BitConverter.Int64BitsToDouble(GetLong(data, offset));
        }
 
        /// <summary>
        /// Puts the short.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <param name="value">The value.</param>
        public static void PutShort(byte[] data, int offset, short value)
        {
            int i = offset;
            data[i++] = (byte)((value >> 0) & 0xFF);
            data[i++] = (byte)((value >> 8) & 0xFF);
            //PutNumber(data, offset, Convert.ToInt64(value), LittleEndianConsts.SHORT_SIZE);
        }
 
        /// <summary>
        /// Added for consistency with other put~() methods
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <param name="value">The value.</param>
        public static void PutByte(byte[] data, int offset, int value)
        {
            data[offset] = (byte)value;
            //PutNumber(data, offset, value, LittleEndianConsts.BYTE_SIZE);
        }
 
 
        /// <summary>
        /// Puts the U short.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <param name="value">The value.</param>
        public static void PutUShort(byte[] data, int offset, int value)
        {
            //PutNumber(data, offset, Convert.ToInt64(value), LittleEndianConsts.SHORT_SIZE);
            int i = offset;
            data[i++] = (byte)((value >> 0) & 0xFF);
            data[i++] = (byte)((value >> 8) & 0xFF);
        }
 
 
        /// <summary>
        /// put a short value into beginning of a byte array
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="value">the short (16-bit) value</param>
        public static void PutShort(byte[] data, short value)
        {
            PutShort(data, 0, value);
        }
 
        /// <summary>
        /// put an int value into a byte array
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <param name="value">the int (32-bit) value</param>
        public static void PutInt(byte[] data, int offset, int value)
        {
            int i = offset;
            data[i++] = (byte)((value >> 0) & 0xFF);
            data[i++] = (byte)((value >> 8) & 0xFF);
            data[i++] = (byte)((value >> 16) & 0xFF);
            data[i++] = (byte)((value >> 24) & 0xFF);
        }
 
        /// <summary>
        /// put an int value into beginning of a byte array
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="value">the int (32-bit) value</param>
        public static void PutInt(byte[] data, int value)
        {
            PutInt(data, 0, value);
        }
 
        /// <summary>
        /// put a long value into a byte array
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <param name="value">the long (64-bit) value</param>
        public static void PutLong(byte[] data, int offset, long value)
        {
            //PutNumber(data, offset, value, LittleEndianConsts.LONG_SIZE);
            int limit = LONG_SIZE + offset;
            long v = value;
 
            for (int j = offset; j < limit; j++)
            {
                data[j] = (byte)(v & 0xFF);
                v >>= 8;
            }
        }
 
 
        /// <summary>
        /// put a double value into a byte array
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <param name="value">the double (64-bit) value</param>
        public static void PutDouble(byte[] data, int offset, double value)
        {
            long lvalue = 0L;
            if (double.IsNaN(value))
            {
                lvalue = -276939487313920L;
                //PutNumber(data, offset, -276939487313920L, LittleEndianConsts.DOUBLE_SIZE);
            }
            else
            {
                lvalue = BitConverter.DoubleToInt64Bits(value);
                //PutNumber(data, offset, BitConverter.DoubleToInt64Bits(value), LittleEndianConsts.DOUBLE_SIZE);
            }
            PutLong(data, offset, lvalue);
        }
 
        /// <summary>
        /// Reads the short.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns></returns>
        public static short ReadShort(Stream stream)
        {
            //return GetShort(ReadFromStream(stream, LittleEndianConsts.SHORT_SIZE));
            return (short)ReadUShort(stream);
        }
 
        public static int ReadUShort(Stream stream)
        {
            int ch1 = stream.ReadByte();
            int ch2 = stream.ReadByte();
            if ((ch1 | ch2) < 0)
            {
                throw new BufferUnderrunException();
            }
            return (ch2 << 8) + (ch1 << 0);
        }
        /// <summary>
        /// get an int value from an Stream
        /// </summary>
        /// <param name="stream">the Stream from which the int is to be read</param>
        /// <returns>the int (32-bit) value</returns>
        /// <exception cref="T:System.IO.IOException">will be propagated back to the caller</exception>
        /// <exception cref="T:HH.WMS.Utils.NPOI.Util.BufferUnderrunException">if the stream cannot provide enough bytes</exception>
        public static int ReadInt(Stream stream)
        {
            //return GetInt(ReadFromStream(stream, LittleEndianConsts.INT_SIZE));
            int ch1 = stream.ReadByte();
            int ch2 = stream.ReadByte();
            int ch3 = stream.ReadByte();
            int ch4 = stream.ReadByte();
            if ((ch1 | ch2 | ch3 | ch4) < 0)
            {
                throw new BufferUnderrunException();
            }
            return (ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0);
        }
 
        /// <summary>
        /// get a long value from a Stream
        /// </summary>
        /// <param name="stream">the Stream from which the long is to be read</param>
        /// <returns>the long (64-bit) value</returns>
        /// <exception cref="T:System.IO.IOException">will be propagated back to the caller</exception>
        /// <exception cref="T:HH.WMS.Utils.NPOI.Util.BufferUnderrunException">if the stream cannot provide enough bytes</exception>
        public static long ReadLong(Stream stream)
        {
            //return GetLong(ReadFromStream(stream, LittleEndianConsts.LONG_SIZE));
            int ch1 = stream.ReadByte();
            int ch2 = stream.ReadByte();
            int ch3 = stream.ReadByte();
            int ch4 = stream.ReadByte();
            int ch5 = stream.ReadByte();
            int ch6 = stream.ReadByte();
            int ch7 = stream.ReadByte();
            int ch8 = stream.ReadByte();
            if ((ch1 | ch2 | ch3 | ch4 | ch5 | ch6 | ch7 | ch8) < 0)
            {
                throw new BufferUnderrunException();
            }
 
            return
                ((long)ch8 << 56) +
                ((long)ch7 << 48) +
                ((long)ch6 << 40) +
                ((long)ch5 << 32) +
                ((long)ch4 << 24) + // cast to long to preserve bit 31 (sign bit for ints)
                      (ch3 << 16) +
                      (ch2 << 8) +
                      (ch1 << 0);
        }
 
        /// <summary>
        /// Us the byte to int.
        /// </summary>
        /// <param name="b">The b.</param>
        /// <returns></returns>
        public static int UByteToInt(byte b)
        {
            return (((b & 0x80) != 0) ? ((b & 0x7f) + 0x80) : b);
        }
 
        /// <summary>
        /// get the unsigned value of a byte.
        /// </summary>
        /// <param name="data">the byte array.</param>
        /// <param name="offset">a starting offset into the byte array.</param>
        /// <returns>the unsigned value of the byte as a 32 bit integer</returns>
        public static int GetUnsignedByte(byte[] data, int offset)
        {
            return data[offset] & 0xFF;
        }
 
 
        /// <summary>
        /// Copy a portion of a byte array
        /// </summary>
        /// <param name="data"> the original byte array</param>
        /// <param name="offset">Where to start copying from.</param>
        /// <param name="size">Number of bytes to copy.</param>
        /// <returns>The byteArray value</returns>
        ///<exception cref="IndexOutOfRangeException">
        ///if copying would cause access ofdata outside array bounds.
        ///</exception>
        public static byte[] GetByteArray(byte[] data, int offset, int size)
        {
            byte[] destinationArray = new byte[size];
            Array.Copy(data, offset, destinationArray, 0, size);
            return destinationArray;
        }
 
        //Are the following methods Obsoleted?
        [Obsolete]
        public static double GetDouble(byte[] data)
        {
            return GetDouble(data, 0);
        }
        [Obsolete]
        public static long GetLong(byte[] data)
        {
            return GetLong(data, 0);
        }
 
 
        [Obsolete]
        public static ulong GetULong(byte[] data)
        {
            return GetULong(data, 0);
        }
        [Obsolete]
        public static ulong GetULong(byte[] data, int offset)
        {
            return BitConverter.ToUInt64(data, offset);
        }
        //[Obsolete] - private method can not be used outside of this class and only obsolete methods are using this method.
        private static long GetNumber(byte[] data, int offset, int size)
        {
            long num = 0L;
            for (int i = (offset + size) - 1; i >= offset; i--)
            {
                num = num << 8;
                num |= 0xffL & data[i];
            }
            return num;
        }
 
        
 
        
 
        
 
        
 
        /// <summary>
        /// Gets the unsigned byte.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <returns></returns>
        [Obsolete]
        public static byte GetUByte(byte[] data)
        {
            return GetUByte(data, 0);
        }
 
        /// <summary>
        /// Gets the unsigned byte.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <returns></returns>
        [Obsolete]
        public static byte GetUByte(byte[] data, int offset)
        {
            return (byte)GetNumber(data, offset, LittleEndianConsts.BYTE_SIZE);
        }
        
 
        
 
        /// <summary>
        /// Puts the double.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="value">The value.</param>
        [Obsolete]
        public static void PutDouble(byte[] data, double value)
        {
            PutDouble(data, 0, value);
        }
 
        
 
        
 
        /// <summary>
        /// Puts the uint.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="value">The value.</param>
        [Obsolete]
        public static void PutUInt(byte[] data, uint value)
        {
            PutUInt(data, 0, value);
        }
 
        /// <summary>
        /// Puts the uint.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <param name="value">The value.</param>
        [Obsolete]
        public static void PutUInt(byte[] data, int offset, uint value)
        {
            PutNumber(data, offset, Convert.ToInt64(value), LittleEndianConsts.UINT_SIZE);
        }
 
        /// <summary>
        /// Puts the long.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="value">The value.</param>
        [Obsolete]
        public static void PutLong(byte[] data, long value)
        {
            PutLong(data, 0, value);
        }
 
        
 
        /// <summary>
        /// Puts the long.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="value">The value.</param>
        [Obsolete]
        public static void PutULong(byte[] data, ulong value)
        {
            PutULong(data, 0, value);
        }
 
        /// <summary>
        /// Puts the ulong.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <param name="value">The value.</param>
        [Obsolete]
        public static void PutULong(byte[] data, int offset, ulong value)
        {
            PutNumber(data, offset, value, LittleEndianConsts.ULONG_SIZE);
        }
 
        /// <summary>
        /// Puts the number.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <param name="value">The value.</param>
        /// <param name="size">The size.</param>
        //[Obsolete] - private method can not be used outside of this class and only obsolete methods are using this method.
        private static void PutNumber(byte[] data, int offset, long value, int size)
        {
            int limit = size + offset;
            long v = value;
            for (int i = offset; i < limit; i++)
            {
                data[i] = (byte)(v & 0xffL);
                v >>= 8;
            }
        }
 
        /// <summary>
        /// Puts the number.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <param name="value">The value.</param>
        /// <param name="size">The size.</param>
        //[Obsolete] - private method can not be used outside of this class and only obsolete methods are using this method.
        private static void PutNumber(byte[] data, int offset, ulong value, int size)
        {
            int limit = size + offset;
            ulong v = value;
            for (int i = offset; i < limit; i++)
            {
                data[i] = (byte)(v & 0xffL);
                v >>= 8;
            }
        }
 
        /// <summary>
        /// Puts the short array.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="offset">a starting offset into the byte array</param>
        /// <param name="value">The value.</param>
        [Obsolete]
        public static void PutShortArray(byte[] data, int offset, short[] value)
        {
            PutNumber( data, offset, Convert.ToInt64(value.Length), LittleEndianConsts.SHORT_SIZE);
            for (int i = 0; i < value.Length; i++)
            {
                PutNumber( data, (offset + 2) + (i * 2), Convert.ToInt64(value[i]), LittleEndianConsts.SHORT_SIZE);
            }
        }
 
        
 
        /// <summary>
        /// Puts the U short.
        /// </summary>
        /// <param name="data">the byte array</param>
        /// <param name="value">The value.</param>
        [Obsolete]
        public static void PutUShort(byte[] data, int value)
        {
            PutNumber(data, 0, Convert.ToInt64(value), LittleEndianConsts.SHORT_SIZE);
        }
 
 
        /// <summary>
        /// Reads from stream.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="size">The size.</param>
        /// <returns></returns>
        [Obsolete]
        public static byte[] ReadFromStream(Stream stream, int size)
        {
            byte[] buffer = new byte[size];
            int num = stream.Read(buffer, 0, buffer.Length);
            if (num == 0)
            {
                for (int i = 0; i < buffer.Length; i++)
                {
                    buffer[i] = 0;
                }
                return buffer;
            }
            if (num != size)
            {
                throw new BufferUnderrunException();
            }
            return buffer;
        }
 
        
 
        /// <summary>
        /// Reads the long.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns></returns>
        [Obsolete]
        public static ulong ReadULong(Stream stream)
        {
            //return GetULong(ReadFromStream(stream, LittleEndianConsts.LONG_SIZE));
            return BitConverter.ToUInt64(ReadFromStream(stream, LittleEndianConsts.LONG_SIZE), 0);
        }
 
        
 
        
    }
    // Nested Types
    [Serializable]
    public class BufferUnderrunException : IOException
    {
        // Methods
        internal BufferUnderrunException()
            : base("buffer underrun")
        {
        }
    }
    [Serializable]
    public class BufferUnderflowException : RuntimeException
    {
        public BufferUnderflowException()
            : base("Buffer Underflow")
        {
        }
    }
}