Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-08-2011, 02:16 PM   PM User | #1
JavaScriptN00B
New to the CF scene

 
Join Date: Sep 2010
Posts: 4
Thanks: 4
Thanked 0 Times in 0 Posts
JavaScriptN00B is an unknown quantity at this point
Java ME, Saving to a text file

Can anyone help me?

Im looking to write the information selected in the Java mobile application to a text file and im not sure where to start, here is the code i have so far:

package hello;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class Rater extends MIDlet implements CommandListener
{
private Display mDisplay;
private Alert mAlert;
private Form mForm;
private ChoiceGroup chcFoodsold, chcEstablishmentType;
private TextField ID, txtPlaceName, txtLocation;
private String strPlace, strLocation, strID;

public Rater()
{
String [] EstablishmentType = {"Bar", "Restaruant", "Cafe'"};
String [] Foodsold = {"Tapas", "Pizza", "Pasta", "English Breakfast", "Roast Dinner", "Pie and Mash"};
mForm = new Form("Enter your order details");
ID = new TextField("ID*: ", null, 4, TextField.NUMERIC);
chcEstablishmentType = new ChoiceGroup("Type of Establishment*", Choice.EXCLUSIVE, EstablishmentType, null);
chcFoodsold = new ChoiceGroup("Food Sold*", Choice.EXCLUSIVE, Foodsold, null);
txtPlaceName = new TextField("Establishment Name*:", null, 15, TextField.ANY);
txtLocation = new TextField("Location*:", null, 15, TextField.ANY);
mForm.append(ID);
mForm.append(txtPlaceName);
mForm.append(txtLocation);
mForm.append(chcEstablishmentType);
mForm.append(chcFoodsold);
mForm.addCommand(new Command("Exit", Command.EXIT, 0));
mForm.addCommand(new Command("Next", Command.SCREEN, 0));
mForm.setCommandListener(this);
mAlert = new Alert("Your order", "", null, AlertType.CONFIRMATION);
mAlert.addCommand(new Command("Back", Command.BACK, 0));
mAlert.addCommand(new Command("Confirm", Command.OK,1));
mAlert.setTimeout(Alert.FOREVER);
}

protected void startApp()
{
mDisplay = Display.getDisplay(this);
mDisplay.setCurrent(mForm);
}


public void commandAction(Command c, Displayable d)
{
if (c.getLabel().equals("Exit"))
{
notifyDestroyed();
}
if (c.getLabel().equals("Next"))
{
strID = ID.getString();
strPlace = txtPlaceName.getString();
strLocation = txtLocation.getString();


String strEstablishmentType = chcEstablishmentType.getString(chcEstablishmentType.getSelectedIndex());
String strFoodsold = "";
for (int i = 0; i < chcFoodsold.size(); i++)
{
if (chcFoodsold.isSelected(i))
{
strFoodsold += "\n" + chcFoodsold.getString(i);
}
}
String strOrderDetails = "ID: " + strID + "ordered " + strFoodsold + " from a \n " + strEstablishmentType + " called " + strPlace + "\n in " + strLocation;
mAlert.setString(strOrderDetails);
mDisplay.setCurrent(mAlert);
}

}

protected void destroyApp(boolean param) {}
protected void pauseApp() {}
}
JavaScriptN00B is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:25 PM.


Advertisement
Log in to turn off these ads.