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

write(int) does not pad the remainder of the current byte with 0s

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta2
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: mlR10151 Date: 03/27/2001



      The descriptions for the FileCacheImageOutputStream:
      public void write(int b)
                 throws IOException
      . . .
            If the bit offset within the stream is non-zero, the remainder of the current byte is padded with
            0s and written out first. The bit offset will be 0 after the write. Implementers can use the
            flushBits method of ImageOutputStreamImpl to guarantee this.
            
            
      But it does not work as expected:
      ===================== a.java =======================
      import java.io.*;
      import javax.imageio.stream.FileCacheImageOutputStream;

      public class a {
          public static void main (String argv[]) throws Exception {
              OutputStream ostream = new ByteArrayOutputStream();
              File f = null;
              FileCacheImageOutputStream fcios = new FileCacheImageOutputStream(ostream, f);
              fcios.writeBit(1);
              fcios.write(96);
          
              fcios.seek(0);

              int r1 = fcios.read();
              if( r1 != 128 ) {
                  System.out.println("Failed1: " + r1);
                  return;
              }

              int r2 = fcios.read();
              if( r2 != 96 ) {
                  System.out.println("Failed2: " + r2);
                  return;
              }
              System.out.println("Passed");
          }
      }
      ===================== log =======================
      java version "1.4.0-internal"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-internal-b57)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b57, mixed mode)
      Failed1: 0

      This bug causes failures of the new JCK test
      api/javax_imageio/stream/FileCacheImageOutputStream/index.html#read

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dricesunw Daniel Rice (Inactive)
              Reporter:
              mlsunw Ml Ml (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: