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

java.awt.swing.text.DefaultEditorKit.read(..) does not throw IOException

    XMLWordPrintable

    Details

      Description



      Name: akC57697 Date: 04/30/98



      java.awt.swing.text.DefaultEditorKit.read(..) does not throw
      IOException.

      The doc says:
      "
      public void read(InputStream in,
                       Document doc,
                       int pos) throws IOException, BadLocationException

          Inserts content from the given stream which is expected to be in a
          format appropriate for this kind
          of content handler.
          Parameters:
             in - The stream to read from
             doc - The destination for the insertion.
             pos - The location in the document to place the content.
          Throws:
             IOException - on any I/O error
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             BadLocationException - if pos represents an invalid location
             within the document.
          Overrides:
             read in class EditorKit"

      ---------------------8-<----------------------
      import java.awt.swing.text.DefaultEditorKit;
      import java.awt.swing.text.Document;
      import java.awt.swing.text.PlainDocument;

      public class DefaultEditorKitTest {
        public static void main( String argv[] ) {

            DefaultEditorKit editor = new DefaultEditorKit();
            Document doc = new PlainDocument();
            
            String string = new String("Test string");
            java.io.StringBufferInputStream in = new java.io.StringBufferInputStream(string);
            
            try {
             in.close();
            } catch (java.io.IOException e) {
              System.out.println("Close :"+e);
              return;
              }
                 
            try {
             editor.read(in,doc,0); // Try to read the closed stream
            } catch (java.io.IOException e) {
                     System.out.println( "OKAY" );
                     return;
                    }
              catch (Exception e) {
                     System.out.println( "Unexpected "+e );
                     return;
              }
             System.out.println( "No IOException !" );
        }
      }
      --------------------->-8----------------------
      Output:
      No IOException !
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            tprinzinsunw Timothy Prinzing (Inactive)
            Reporter:
            akuzminorcl Alexander Kuzmin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: