Guava入门~Charsets
生活随笔
收集整理的這篇文章主要介紹了
Guava入门~Charsets
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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));}
}
總結
以上是生活随笔為你收集整理的Guava入门~Charsets的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 掌控谈话~标注对方的痛苦
- 下一篇: ThreadLocal与Synchron