Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4422277

ImageInputStreamImpl.readFully(short[],int,int) fails

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.3.1
    • client-libs



      Name: krC82822 Date: 03/06/2001


      java version "1.3.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-beta-b15)
      Java HotSpot(TM) Client VM (build 1.3.1beta-b15, mixed mode)

      1.------
      Use
      method void readFully(short[],int,int)
      of
      class javax.imageio.stream.FileImageInputStream
      or
      class javax.imageio.stream.MemoryCacheImageInputStream
      reading 2 bytes > 0x7F

      2.------
      import java.io.*;
      import javax.imageio.stream.*;

      public class ImageIoReadShortTest extends Object {

          public static void main (String args[]) {
              try {
                  byte[] b = {
                      (byte)0x01, (byte)0x23,
                      (byte)0x45, (byte)0x67,
                      (byte)0x89, (byte)0xAB,
                      (byte)0xCD, (byte)0xEF };
                  InputStream in = new ByteArrayInputStream(b);
                  ImageInputStream iin = new MemoryCacheImageInputStream(in);
                  iin.setByteOrder(true);
                  short[] s = new short[b.length/2];
                  iin.readFully(s,0,s.length);
                  for (int i = 0; i < s.length; ++i) {
                      System.out.println(Integer.toHexString(s[i]));
                  }
              }
              catch (Exception ex) {
                  ex.printStackTrace();
              }
          }
      }

       > java -cp .:../lib/imageio.jar ImageIoReadShortTest
      123
      4567
      ffffffab { should be 89ab }
      ffffffef { should be cdef }
      (Review ID: 118073)
      ======================================================================

            Unassigned Unassigned
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: