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

InputStreamReader mark/reset/markSupported should delegate to underlying stream

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      Name: apC94908 Date: 02/25/2000



      Spec for java.io.Reader says:
      ---------------
      public void mark(int readAheadLimit)
                throws IOException

           Mark the present position in the stream. Subsequent calls to reset() will attempt to
           reposition the stream to this point. Not all character-input streams support the mark()
           operation.
           Parameters:
                readAheadLimit - Limit on the number of characters that may be read while
                still preserving the mark. After reading this many characters, attempting to reset
                the stream may fail.
           Throws:
                IOException - If the stream does not support mark(), or if some other I/O error
                                            _______________________
                occurs
      ---------------

      But it throws IOException on mark operation even if underlying
      InputStream support mark - ByteArrayInputStream, for example

      ----- Test.java
      import java.io.*;
      public class Test {

          public static void main(String[] args) throws IOException {
              byte[] ba = new byte[10];
      // InputStreamReader inherits mark from Reader
              InputStreamReader isr = new InputStreamReader(new
                      ByteArrayInputStream(ba));
              isr.mark(5);
          }
      }
      ----- Output
      Exception in thread "main" java.io.IOException: mark() not supported
      at java.io.Reader.mark(Reader.java:194)
      at Test.main(Test.java:8)
      -----

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

        Attachments

          Activity

            People

            Assignee:
            mr Mark Reinhold
            Reporter:
            avpsunw Avp Avp (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: