Click here to Skip to main content
16,006,709 members
Home / Discussions / Java
   

Java

 
GeneralRe: CORRECTION FOR MA CODE: Dr Phils Personality test Pin
fly9047-Aug-09 11:39
fly9047-Aug-09 11:39 
GeneralRe: CORRECTION FOR MA CODE: Dr Phils Personality test Pin
fly9047-Aug-09 11:56
fly9047-Aug-09 11:56 
Generalthanks Pin
Ogunjimi Adewale8-Aug-09 11:17
Ogunjimi Adewale8-Aug-09 11:17 
QuestionBottom toolbar like facebook application Pin
sangeethanarayan5-Aug-09 1:04
sangeethanarayan5-Aug-09 1:04 
AnswerRe: Bottom toolbar like facebook application Pin
fly9045-Aug-09 2:20
fly9045-Aug-09 2:20 
QuestionJ2me: wireless tookit error. Pin
udombat4-Aug-09 21:24
udombat4-Aug-09 21:24 
AnswerRe: J2me: wireless tookit error. Pin
carlospc19705-Aug-09 4:38
professionalcarlospc19705-Aug-09 4:38 
GeneralRe: J2me: wireless tookit error. Pin
udombat5-Aug-09 5:18
udombat5-Aug-09 5:18 
is there anything wrong with this code?

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

public class FileConnection extends MIDlet implements CommandListener {
  private Command exit, start;
  private Display display;
  private Form form;
  public FileConnection () 
  {
    display = Display.getDisplay(this);
    exit = new Command("Exit", Command.EXIT, 1);
    start = new Command("Start", Command.EXIT, 1);
    form = new Form("Write To File");
    form.addCommand(exit);
    form.addCommand(start);
    form.setCommandListener(this);
  }
  public void startApp() throws MIDletStateChangeException 
  {
    display.setCurrent(form);
  }
  public void pauseApp() 
  {
  }
  public void destroyApp(boolean unconditional) 
  {
  }
  public void commandAction(Command command, Displayable displayable) 
  {
    if (command == exit) 
    {
      destroyApp(false);
      notifyDestroyed();
    }
    else if (command == start) 
    {
      try 
      {
        OutputConnection connection = (OutputConnection)                     
          Connector.open("file://c:/myfile.txt;append=true", Connector.WRITE );
        OutputStream out = connection.openOutputStream();
        PrintStream output = new PrintStream( out );
        output.println( "This is a test." );
        out.close();
        connection.close();
        Alert alert = new Alert("Completed", "Data Written", null, null);
        alert.setTimeout(Alert.FOREVER);
        alert.setType(AlertType.ERROR);
        display.setCurrent(alert);      
      }
      catch( ConnectionNotFoundException error )
       {
         Alert alert = new Alert(
              "Error", "Cannot access file.", null, null);
         alert.setTimeout(Alert.FOREVER);
         alert.setType(AlertType.ERROR);
         display.setCurrent(alert);      
        }
        catch( IOException error )
        {
         Alert alert = new Alert("Error", error.toString(), null, null);
         alert.setTimeout(Alert.FOREVER);
         alert.setType(AlertType.ERROR);
         display.setCurrent(alert);      
        }
    }
  }

GeneralRe: J2me: wireless tookit error. Pin
carlospc19705-Aug-09 5:47
professionalcarlospc19705-Aug-09 5:47 
GeneralRe: J2me: wireless tookit error. Pin
udombat5-Aug-09 6:52
udombat5-Aug-09 6:52 
GeneralRe: J2me: wireless tookit error. Pin
carlospc19705-Aug-09 7:05
professionalcarlospc19705-Aug-09 7:05 
QuestionASP.Net with Java Windows Pin
PDTUM4-Aug-09 17:02
PDTUM4-Aug-09 17:02 
QuestionMozilla Firefox Pin
TCSJoe3-Aug-09 18:29
TCSJoe3-Aug-09 18:29 
AnswerRe: Mozilla Firefox Pin
fly9044-Aug-09 7:29
fly9044-Aug-09 7:29 
Questionout of heap Exception Pin
shammasi31-Jul-09 20:24
shammasi31-Jul-09 20:24 
AnswerRe: out of heap Exception Pin
42774803-Aug-09 20:08
42774803-Aug-09 20:08 
GeneralRe: out of heap Exception Pin
shammasi3-Aug-09 20:51
shammasi3-Aug-09 20:51 
QuestionFingerprint Reader Pin
-=spike=-30-Jul-09 19:26
-=spike=-30-Jul-09 19:26 
GeneralRe: Fingerprint Reader Pin
Kujtim Hyseni31-Jul-09 2:50
Kujtim Hyseni31-Jul-09 2:50 
QuestionHow to respond/reply to a Server Cookie ? - trying to make a Java Web Browser. Pin
icyrohit30-Jul-09 18:31
icyrohit30-Jul-09 18:31 
QuestionDisplay Table in JSP Pin
<<Tash18>>30-Jul-09 2:50
<<Tash18>>30-Jul-09 2:50 
AnswerRe: Display Table in JSP Pin
David Skelly30-Jul-09 22:19
David Skelly30-Jul-09 22:19 
AnswerRe: Display Table in JSP Pin
Centurion12351-Aug-09 21:07
Centurion12351-Aug-09 21:07 
GeneralRe: Display Table in JSP Pin
David Skelly2-Aug-09 22:31
David Skelly2-Aug-09 22:31 
AnswerRe: Display Table in JSP Pin
42774803-Aug-09 20:06
42774803-Aug-09 20:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.