Reading Unicode files in JavaME

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Created: senthilkumar05 (27 Dec 2007)
Last edited: hamishwillee (15 Oct 2013)

Warning.pngThis article does not meet the wiki quality standards: Please make it more useful by adding links or additional information as discussed in the quality standards. When you have done so you can delete the {{NeedsMoreWork}} template from the article to remove this warning.

This article demonstrates how to read unicode files using Java ME. The following method reads the unicode file, returning a string with the file name:

public String readUnicodeFile(String filename) {
StringBuffer buffer = null;
InputStream is = null;
InputStreamReader isr = null;
try {
Class c = this.getClass();
is = c.getResourceAsStream(filename);
if (is == null) throw new Exception("File Does Not Exist");
isr = new InputStreamReader(is,"UTF8");
buffer = new StringBuffer();
int ch;
while ((ch = isr.read()) > -1) {
if (isr != null) isr.close();
}catch (Exception ex) {
return buffer.toString();
* This Sample Midlet reads of the Unicode Characters and displays

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.midlet.MIDlet;
public class UnicodeTest extends MIDlet {
Display display;
Form form = null;
StringItem msg = null;
public UnicodeTest() {}
public void startApp() {
display = Display.getDisplay(this);
msg = new StringItem("'Hello World' in Japanese","u3053u3093u306Bu3061u306Fu4E16u754C");
form = new Form("Unicode Test");
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
This page was last modified on 15 October 2013, at 04:02.
35 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.