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

(str) Add a getChars method to java.lang.CharSequence

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 6
    • core-libs
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      String and AbstractStringBuilder both have a

       public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)

      method. Unfortunately this method is not in CharSequence.

      JUSTIFICATION :
      java.lang.CharSequence has a method

       CharSequence subSequence(int start, int end)

      to get parts of the sequence. So there is no reason why there shouldn't be also a

       public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)

      to read character data efficiently into an existind buffer. This would allow for efficient generalizations.

      Example:
      StringReader then could take CharSequence as construction parameter wo wrap arbitrary CharSequences in Readers. It could then copy character data while avoiding unneccessary in-memory copies of these data.


      CUSTOMER SUBMITTED WORKAROUND :
      Make case differentiations between String, StringBuffer, StringBuilder,...

            martin Martin Buchholz
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: