gbk轉(zhuǎn)utf8最簡(jiǎn)單的方法 如何將utf-8編碼的文件轉(zhuǎn)換成gbk?
如何將utf-8編碼的文件轉(zhuǎn)換成gbk?你好,我是【王小利的故事】,很高興為你解答。java不同編碼之間進(jìn)行轉(zhuǎn)換,都需要使用unicode作為中轉(zhuǎn)。以u(píng)tf-8轉(zhuǎn)gbk為例,示例代碼如下: Strin
如何將utf-8編碼的文件轉(zhuǎn)換成gbk?
你好,我是【王小利的故事】,很高興為你解答。java不同編碼之間進(jìn)行轉(zhuǎn)換,都需要使用unicode作為中轉(zhuǎn)。以u(píng)tf-8轉(zhuǎn)gbk為例,示例代碼如下: String t = "這是一個(gè)字符串a(chǎn)aa111" String utf8 = new String(t.getBytes( "UTF-8")) System.out.println(utf8) String unicode = new String(utf8.getBytes(),"UTF-8") System.out.println(unicode) String gbk = new String(unicode.getBytes("GBK")) System.out.println(gbk)更多專業(yè)的科普知識(shí),歡迎關(guān)注我。如果喜歡我的回答,也請(qǐng)給我贊或轉(zhuǎn)發(fā),你們的鼓勵(lì),是支持我寫下去的動(dòng)力,謝謝大家。
如何將gbk字符文件轉(zhuǎn)為utf8字符文件?
讀入: BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fileFrom), Charset.forName("GBK")))
寫出: BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileTo), Charset.forName("UTF-8")))