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

fp.bugs 4170 System.in.read encounters an EOF, next out.println not output

XMLWordPrintable

    • sparc
    • solaris_2.5

       From: ###@###.###
      This does not look like form output to me.


      I found a bug in the JDK 1.0 under Windows 95:


      /* This Java application demonstrates a bug in the "standard I/O
       * routines" provided by System.in.read and System.out.println. If
       * System.in.read encounters an EOF character (CTRL-Z on PC's),
       * and you call System.out.println immediately afterwards,
       * System.out.println doesn't print the first line it is given.
       * (Note, however, that if the first println call after read()
       * has more than one line (using "\\n"), then only the first line in
       * the argument doesn't print.)
       */

      class SysErr {
          public static void main(String args[])
              throws java.io.IOException
          {
              System.out.println("Type anything you want. If you use " +
                                  "the EOF character,");
              System.out.println("Only one line will appear below.");
              System.in.read();

              System.out.println("Line 1"); // this doesn't appear !
              System.out.println("Line 2");
          }
      }


      --------------------------------------
      Oren Hurvitz
      E-mail: ###@###.###
      (Include "oren" on the subject line to make sure I receive the email)
      --------------------------------------

       

            mr Mark Reinhold
            bhagen Benjamin Hagen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: