How to read Unicode and UTF-8 Encoding File in J2ME
This article shows you how to read Unicode and UTF-8 encoded files in J2ME. The content is concise and easy to understand. It will definitely make your eyes shine. I hope you can gain something from the detailed introduction of this article.
J2ME has a more diverse environment and goals than J2SE and J2EE, but each product has a more singular purpose and stricter resource constraints.
Reading Unicode and UTF-8 encoded files in J2ME
J2ME reads Unicode files
/** * Read Unicode encoded text files *@paramresourceString-filename *@returnString-Unicode text */ publicstaticStringread_Uni(Stringresource){ byteword_uni[]=newbyte[1024]; StringStrReturn=null; InputStreamis; try{ is=instance.getClass().getResourceAsStream(resource); is.skip(2);//Skip two-byte headers is.read(word_uni); is.close(); StringBufferstringbuffer=newStringBuffer(""); for(intj=0;j