#000655    

#def   ,      -      .      j2me       ,     ASCII  . 

private String getText(String path) {
        DataInputStream dis = new DataInputStream(getClass().getResourceAsStream(path));
        StringBuffer strBuff = new StringBuffer(); 
        int ch = 0;
        try {
            while ((ch = dis.read()) != -1) {
                strBuff.append((char ) ((ch >= 0xc0 && ch <= 0xFF) ? (ch + 0x350) : ch));
            }
            dis.close();
        } catch (Exception e) {
            System.err.println("ERROR in getText() " + e);
        }
        return strBuff.toString();
}

     ,    java   java.io.*.     getText    .    res/  .  , getText(/book.txt)   < >/res/book.txt. (  ,    jar          ,     .) 

 ,  .     dis,    ,        strBuff,         . 

         : 

strBuff.append((char) ((ch >= 0xc0 && ch <= 0xFF) ? (ch + 0x350) : ch)); 

  ,     

strBuff.append((char)ch) 

    ,          .           ASCII  Unicode. 

        .   .   SampleMidlet       .        StringItem,       .  ,    . 

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
//     /
import java.io.*;          

public class SampleMIDlet extends MIDlet implements CommandListener{

    private Display display;
    private Form MainForm; //
    private StringItem StrFromTxt; //,      
    private Command CMD_EXIT = new Command("", Command.EXIT, 1); //    

    public SampleMIDlet(){}

    protected void destroyApp( boolean unconditional ) throws MIDletStateChangeException 
     {
       exitApp();
      }

    protected void pauseApp(){}

    protected void startApp() throws MIDletStateChangeException
     {
         if( display == null )
              { 
                  initApp( ); //      
              } 
     }

    private void initApp()
     {
       display = Display.getDisplay( this );
         MainForm = new Form("www.MobiLab.ru"); // 
         MainForm.setCommandListener(this); ///    
         MainForm.addCommand(CMD_EXIT); //    

         String str=getText("/book.txt"); //      
         
         // StringItem     
         StrFromTxt = new StringItem("?????: ",str); 
         
         MainForm.append(StrFromTxt); //     
         display.setCurrent(MainForm); // 
     }

    public void exitApp()
     {
         notifyDestroyed(); //  MIDlet-
     }

    public void commandAction(Command c, Displayable d) {
        if (c == CMD_EXIT){exitApp();}     // ""
    }

private String getText(String path) {
        DataInputStream dis = new DataInputStream(getClass().getResourceAsStream(path));
        StringBuffer strBuff = new StringBuffer(); 
        int ch = 0;
        try {
            while ((ch = dis.read()) != -1) {
                strBuff.append((char ) ((ch >= 0xc0 && ch <= 0xFF) ? (ch + 0x350) : ch));
            }
            dis.close();
        } catch (Exception e) {
            System.err.println("ERROR in getText() " + e);
        }
        return strBuff.toString();
} 

}

C   /res/    book.txt  - . ,     . 
    

       ,       .      - ( '|').       ,           getText(),        .     ,       (int, double). 
 .       :  ,     (    :) ).    res   config.ini   

|1973|86.998| 

    .     initApp(): 

    private void initApp()
     {
      display = Display.getDisplay( this );
         MainForm = new Form("www.MobiLab.ru"); // 
         MainForm.setCommandListener(this); 
         MainForm.addCommand(CMD_EXIT);
         display.setCurrent(MainForm); // 
          //    
         String str=getText("/config.ini"); //     
      
         int i0=0, i=0;
         String s1; // . (  )

         i = str.indexOf("|",i0+1); //  "|"  ,   i0+1 
         String Name=str.substring(i0,i); //    i0  i- 

         i0=i;
         i = str.indexOf("|",i0+1); //  
         s1=str.substring(i0+1,i);
         int Year=(int)Integer.parseInt(s1); //   
        
         i0=i;
         i = str.indexOf("|",i0+1); //  
         s1=str.substring(i0+1,i);
         double Weight=(double)Double.parseDouble(s1); //    

         StringItem SI1= new StringItem(": ",Name); 
         StringItem SI2= new StringItem(": ",""+Year); 
         StringItem SI3= new StringItem(": ",""+Weight); 
         MainForm.append(SI1);
         MainForm.append(SI2);
         MainForm.append(SI3);
     }

 ,  . 
  i0     . 
   indexOf()   ,   i0 
  substring          
      
   1