| private String read_Uni(String resource) { byte word_uni[]=new byte[1024]; String strReturn=""; InputStream is; try { is=getClass().getResourceAsStream(resource); is.read(word_uni); is.close(); StringBuffer stringbuffer = new StringBuffer(""); for (int j = 0; j < word_uni.length; ) { int k = word_uni[j++]; //注意在这个地方进行了码制的转换 if (k < 0) k += 256; int l = word_uni[j++]; if (l < 0) l += 256; char c = (char) (k + (l << 8)); //把高位和低位数组装起来 stringbuffer.append(c); } strReturn=stringbuffer.toString(); } catch(IOException e) finally return strReturn; } |
| private String read_Uni_b_e(String resource) { char word_uni_b_e[]=new char[1024]; String strReturn=""; DataInputStream dis; try { dis=new DataInputStream(getClass().getResourceAsStream(resource)); int counter=0; dis.skip(2); char temp; while(true) dis.close(); strReturn=String.valueOf(word_uni_b_e,0,counter); } catch(Exception e) { System.out.println("read_Uni_b_e error!"+e.getMessage()); } finally return strReturn; } |
| Operation System: Microsoft Windows XP Professional Service Pack 1 Emulator: Sun Wireless ToolKit 2.2 beta DefaultColorPhone |
用户评论