Java语言的中文处理

Java char 16 位, Java 型。 使 16 Java Unicode 符, 使 Java Unicode 言, 好。 是, 示, 串, 题。 OakJava 号) Unix Unix 统, 说, 便 ISO Latin-1 地, Unix 性, Java I/O Unix 型, Unix 中, I/O 8 示。 I/O Unix 法, 使 Java 16 Java 符, 8 备, Java 足。 Java 8 方, 码, " (hack)" 8 16 Unicode 16 Unicode 8 符。

 

例子:

下面程序代码:说名利用InputStringReader类,从原始的byte数据来转换成既定的字符集

 

import java.io.*;

 

public class rfnew

{

 

public static void main(String args[])

{

 

       FileInputStream fis;

 

       InputStreamReader  isr;

 

       char ch;

 

       try

       {

 

              fis = new FileInputStream("gq.txt");

 

              isr = new InputStreamReader(fis);

 

              while (true)

              {

 

                     ch = (char) isr.read();

 

                     System.out.print(ch);

 

                     System.out.flush();

 

                     if (ch == '/n') break;

 

              }

 

              fis.close();

 

       }

       catch (Exception e) { }

 

       System.exit(0);

 

}

 

}

 

InputStringReader类的说明:

An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes them into characters using a specified charset. The charset that it uses may be specified by name or may be given explicitly, or the platform's default charset may be accepted.

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值