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

string.trim() doesn't trim trailing white space.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.0beta
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Not verified

      Description

      This program:

      class Main {
          public static void main (String args[]) {

      String one = "no white space";
      String two = " leading white space";
      String three = "trailing white space ";
      String four = " leading and trailing white space ";
      System.out.println("\\"" + one.trim() + "\\"");
      System.out.println("\\"" + two.trim() + "\\"");
      System.out.println("\\"" + three.trim() + "\\"");
      System.out.println("\\"" + four.trim() + "\\"");
          }
      }


      yields this output:

      "no white space"
      "leading white space"
      "trailing white space "
      "leading and trailing white space "

      Note that the trailing white space on the last two lines of output has not been trimmed.

      fy-
      I'll take this one. It's a trivial bug, and I'm looking at String.java anyway. . ..

        Attachments

          Activity

            People

            Assignee:
            fyellinsunw Frank Yellin (Inactive)
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: