import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class IndexMIDlet extends MIDlet
{
private ResourceBundle indexBundle;
private Display display;
private TextBox box;
protected void startApp() throws MIDletStateChangeException
{
display = Display.getDisplay(this);
try
{
indexBundle = new ResourceBundle("/index.properties",15);
}
catch(IOException e)
{
e.printStackTrace();
}
box = new TextBox("IndexBundle",null,256,TextField.ANY);
box.setString(indexBundle.getString(2));
display.setCurrent(box);
}
protected void pauseApp()
{
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException
{
}
}
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Vector;
public class ResourceBundle
{
private Vector indexVector;
private String fileName;
private ResourceBundle()
{
}
public ResourceBundle(String fileName, int size) throws IOException
{
this.fileName = fileName;
indexVector = new Vector(size);
init();
}
private InputStream getInputStreamFromFile()
{
return new ResourceBundle().getClass().getResourceAsStream(
fileName);
}
private void init() throws IOException
{
readToVector();
}
public String getString(int indexID)
{
if (indexID < 0 || indexID > indexVector.size())
{
return null;
} else
{
return (String) indexVector.elementAt(indexID);
}
}