Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.UnsupportedEncodingException;

public class Main {
    public static final String ENCODE_CHARSET = "UTF-8";

    public static byte[] getBytes(String str) {
        if (str != null) {
            try {
                return str.getBytes(ENCODE_CHARSET);
            } catch (UnsupportedEncodingException e) {
                return str.getBytes();
            }
        } else {
            return new byte[0];
        }
    }
}