Java UTF8 asUTFString(byte[] content)

Here you can find the source of asUTFString(byte[] content)

Description

as UTF String

License

Open Source License

Declaration

public static String asUTFString(byte[] content) 

Method Source Code


//package com.java2s;
/*/*w  w w.  ja v a2s  .co m*/
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */

import java.nio.charset.StandardCharsets;

public class Main {
    public static final String EMPTY = "";

    public static String asUTFString(byte[] content) {
        return asUTFString(content, 0, content.length);
    }

    public static String asUTFString(byte[] content, int offset, int length) {
        return (content == null || length == 0 ? EMPTY
                : new String(content, offset, length, StandardCharsets.UTF_8));
    }
}

Related

  1. asUtf8(byte[] bytes)
  2. asUTF8(InputStream in)
  3. asUTF8bytes(String s)
  4. asUtf8ByteStream(final String string)
  5. asUTF8String(byte[] bytes)
  6. backup(String inputFile, String backupFile)
  7. codeListToString(List utf8CodeList)
  8. codesToString(int[] utf8Codes)
  9. codeToString(int utf8Code)