Byte array based Scanner has no constructor that takes a Charset

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P5
    • None
    • Affects Version/s: 7
    • Component/s: core-libs

      A DESCRIPTION OF THE REQUEST :
      There is no constructor of java.util.Scanner that takes a java.nio.charset.Charset
      intead of a String to specify a charset for byte stream.

      I propose to add 3 constructors:
      - Scanner(File source, Charset charset)
      - Scanner(InputStream source, Charset charset)
      - Scanner(ReadableByteChannel source, Charset charset)


      JUSTIFICATION :
      charset specified as a String has 3 problems :
      - it's error prone to use a String because it's easy to malform it
      - sometimes you have a Charset in that case, you have to
        transform it to a String and the Scanner implementation
        will retransform it to a Charset.
      - the implementation use a thread local cache which is
        not necessary if you know the Charset


      CUSTOMER SUBMITTED WORKAROUND :
      Use String based constructors.

            Assignee:
            Xueming Shen
            Reporter:
            Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: