import java.io.UnsupportedEncodingException;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import com.google.common.base.Charsets;/*** TODO 在此写上类的相关说明.<br>* @author gqltt<br>* @version 1.0.0 2021年11月11日<br>* @see * @since JDK 1.5.0*/
public class CharsetsDemo {public static void main(String[] args) {decode();}static void decode() {byte[] bytes = null;try{bytes = "foobarbaz".getBytes("UTF-8");} catch (UnsupportedEncodingException e) {//This really can't happen UTF-8 must be supported}byte[] bytes2 = "foobarbaz".getBytes(Charsets.UTF_8);Assert.assertThat(bytes, CoreMatchers.is(bytes2));}
}