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

java.io: Add support for simple input parsing

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.1, 1.1.7
    • core-libs
    • generic, x86
    • solaris_2.5, windows_98

      There needs to be a class in java.io that can take ASCII/Unicode input from
      the keyboard for all the primitive types.

      Currently the only built-in support is for binary data. That is almost
      never what is wanted for terminal I/O.

      The class should be called something like PrintInputStream and it would
      read character date and assemble it into values of the primitive types.
      Currently, programmers are obliged to do this by hand, forming the worst
      possible impression on those new to the language. Even Pascal has better
      support than this. Even C has better support than this. Even C++ has better
      support than this.

      This is how we must currently read an integer from System.in

              import java.util.*;
              static DataInputStream dis = new DataInputStream( System.in );
              static StringTokenizer st;

          try {
              st=new StringTokenizer(dis.readLine());
              int myint = Integer.parseInt(st.nextToken());


      We have to offer something a bit better!

      peter.vanderlinden@Eng 1996-09-15

            mr Mark Reinhold
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: