技术分享 J2ME中读取Unicode和UTF-8编码文件(1)(2)
二、J2ME读取UTF-8文件 /** *读取UTF-8编码文本文件 *@paramresourceString-文件名 *@returnString-UTF-8文本 */ publicstaticStringread_UTF(Stringresource){ byteword_utf[]=newbyte[1024]; S
二、J2ME读取UTF-8文件
- /**
- *读取UTF-8编码文本文件
- *@paramresourceString-文件名
- *@returnString-UTF-8文本
- */
- publicstaticStringread_UTF(Stringresource){
- byteword_utf[]=newbyte[1024];
- StringstrReturn=null;
- InputStreamis;
- try{
- is=instance.getClass().getResourceAsStream(resource);
- is.read(word_utf);
- is.close();
- strReturn=newString(word_utf,"UTF-8");
- }catch(IOExceptionex){
- System.out.println(ex);
- }
- returnstrReturn;
- }
精彩图集
精彩文章