Java Charset Create getEncodedStringLength(String str)

Here you can find the source of getEncodedStringLength(String str)

Description

get Encoded String Length

License

Open Source License

Declaration

static int getEncodedStringLength(String str) 

Method Source Code


//package com.java2s;
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

import java.nio.charset.Charset;

public class Main {
    private static final Charset UTF8 = Charset.forName("UTF-8");

    static int getEncodedStringLength(String str) {
        return encodeString(str).length;
    }/*from   w w  w . jav a2 s. c o  m*/

    static byte[] encodeString(String str) {
        return str.getBytes(UTF8);
    }
}

Related

  1. getCharsetOrDefault(String charsetName)
  2. getDefaultCharset()
  3. getDefaultCharset()
  4. getDefaultCharsetName()
  5. getDefaultSystemCharset()
  6. getEncodedUrl(String unEncodedUrl)
  7. getEncoder()
  8. getEncoder()
  9. getEncoder()