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

Method for binary data in strings

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P5
    • Resolution: Not an Issue
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      A DESCRIPTION OF THE REQUEST :
      Because Sun Microsystems deprecated the following methods (of the java.lang.String class):

      1. String(byte[] ascii, int hibyte)
      2. String(byte[] ascii, int hibyte, int offset, int count)
      3. void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin)

      it is inconvenient to use the java.lang.String class to store binary data, though this is often a useful thing to do.

      JUSTIFICATION :
      Using java.lang.String is useful because unlike with byte[], one can use methods such as indexOf, to search through data.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Methods specified above should not be deprecated or some other means of allowing binary data in java.lang.String (i.e. with a new Charset called "BINARY")

      ACTUAL -
      Instead, to read binary data into a java.lang.String, one must use a loop (or the deprecated methods). Writing binary data is ok (using ok in the "not entirely pleasing" sense, because the DataOutputStream.writeBytes (String) handles this fairly well, at least for writing to output streams).

      CUSTOMER SUBMITTED WORKAROUND :
      byte[] input...
      ...
      String readString = new String (input, 0);

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              iris Iris Clark
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: