KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > microedition > midlet > MIDlet

javax.microedition.midlet
Class MIDlet

java.lang.Object
  |
  +--javax.microedition.midlet.MIDlet
See Also:
Top Examples, Source Code

public final int checkPermission(String permission)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract void destroyApp(boolean unconditional)
                            throws MIDletStateChangeException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1291]MIDletDemo
By Anonymous on 2005/02/02 10:25:55  Rate
import java.io.*; 
 import java.util.*; 
 import javax.microedition.io.*; 
 import javax.microedition.midlet.*; 
 import javax.microedition.io.file.*; 
  
  
 public class MIDletDemo extends MIDlet  {  
  
  
    public void startApp (  )   {  
       System.out.println ( "MIDlet Started...." ) ; 
       getRoots (  ) ; 
       GetSDcardContent (  ) ; 
       //showFile ( "readme.txt" ) ; 
     }  
  
  
    public void pauseApp (  )   {  
     }  
  
  
    public void destroyApp ( boolean condition )   {  
       notifyDestroyed (  ) ; 
     }  
  
  
    private void getRoots (  )   {  
       Enumeration drives = FileSystemRegistry.listRoots (  ) ; 
       System.out.println ( "The valid roots found are: " ) ; 
       while ( drives.hasMoreElements (  )  )   {  
          String root =  ( String )  drives.nextElement (  ) ; 
          System.out.println ( "\t"+root ) ; 
        }  
     }  
  
  
    private void GetSDcardContent (  )   {  
       try  {  
          FileConnection fc =  ( FileConnection )  
             Connector.open ( "file:///CFCard/" ) ; 
          // Get a filtered list of all files and directories. 
          // True means: include hidden files. 
          // To list just visible files and directories, use 
          // list (  )  with no arguments. 
          System.out.println 
              ( "List of files and directories under CFCard:" ) ; 
          Enumeration filelist = fc.list ( "*", true ) ; 
          while ( filelist.hasMoreElements (  )  )   {  
             String fileName =  ( String )  filelist.nextElement (  ) ; 
             fc =  ( FileConnection )  
                Connector.open ( "file:///CFCard/" + fileName ) ; 
             if ( fc.isDirectory (  )  )   {  
                System.out.println ( "\tDirectory Name: " + fileName ) ; 
              }  else  {  
                System.out.println 
                    ( "\tFile Name: " + fileName +  
                    "\tSize: "+fc.fileSize (  )  ) ; 
              }  
              
           }     
          fc.close (  ) ; 
        }  catch  ( IOException ioe )   {  
          System.out.println ( ioe.getMessage (  )  ) ; 
        }  
     }  
  
  
    public void showFile ( String fileName )   {  
       try  {  
          FileConnection fc =  ( FileConnection )  
             Connector.open ( "file:///CFCard/" + fileName ) ; 
          if ( !fc.exists (  )  )   {  
             throw new IOException ( "File does not exist" ) ; 
           }  
          InputStream is = fc.openInputStream (  ) ; 
          byte b [  ]  = new byte [ 1024 ] ; 
          int length = is.read ( b, 0, 1024 ) ; 
          System.out.println 
              ( "Content of "+fileName + ": "+ new String ( b, 0, length )  ) ; 
        }  catch  ( Exception e )   {  
        }  
     }  
  } 


public final String getAppProperty(String key)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected MIDlet()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final void notifyDestroyed()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final void notifyPaused()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract void pauseApp()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final boolean platformRequest(String URL)
                              throws ConnectionNotFoundException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final void resumeRequest()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract void startApp()
                          throws MIDletStateChangeException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags