Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE

import java.io.UnsupportedEncodingException;

public class Main {
    /**
     * encodes the given charArray as UTF8 encoded byte array.
     * @param charArray      char array to be encoded
     * @return            UTF8 encoded byte array 
     * @throws UnsupportedEncodingException   if UTF8 encoding is not supported
     */
    public static byte[] utf8Encoder(char[] charArray) throws UnsupportedEncodingException {
        String javaString = new String(charArray);
        return javaString.getBytes("UTF8");
    }
}