wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes writing to text files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "writing to text files" Watch "writing to text files" New topic
Author

writing to text files

Igbe Jr. Chukwudi
Greenhorn

Joined: Nov 29, 2010
Posts: 12
package KnowledgeONWeb;
/*
* Form.java
*
* Created on November 10, 2010, 12:02 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

/**
*
* @author Administrator
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.io.RandomAccessFile;
import java.util.*;
import KnowledgeONWeb.FormLogic;
import KnowledgeONWeb.Form1;
public class Form extends JFrame implements Serializable
{
/** Creates a new instance of Form */
private JLabel applicationFormLabel;
private JLabel applyingForLabel;
private JLabel graduationDegreeProgramLabel;
private JLabel schoolLabel;
private JLabel personalDetailsLabel;
private JLabel nameLabel;
private JLabel nameOrderLabel;
private JTextField nameText;
private JLabel addressLabel;
private JTextField addressText;
private JTextField cityText;
private JLabel cityLabel;
private JLabel stateLabel;
private JTextField statetext;
private JLabel OtherstatesLabel;
private JLabel zipcodeLabel;
private JLabel countryLabel;
private JTextField zipcodeText;
private JTextField countryText;
private JLabel phoneLabel;
private JLabel countrycodeLabel;
private JLabel areacodeLabel;
private JLabel phonenumberLabel;
private JTextField countrycodeText;
private JTextField areacodeText;
private JTextField phonenumberText;
private JLabel officephoneLabel;
private JTextField officephoneText;
private JLabel emailaddressLabel;
private JTextField emailaddressText;
private JLabel genderLabel;
private JRadioButton maleButton;
private JRadioButton femaleButton;
private JLabel dateofbirthLabel;
private JTextField dateofbirthText;
private JLabel monthdayyearLabel;
private JLabel citizenstatusLabel;
private JButton continueButton;



private FlowLayout layout;

private JPanel graduationDegreeProgramPanel;
private JPanel applicationFormPanel;
private JPanel applyingForPanel;
private JPanel schoolPanel;
private JPanel panelForSchoolAndGDP;
private JPanel personalDetailsPanel;
private JPanel namePanel;
private JPanel nameTextPanel;
private JPanel nameOrderPanel;
private JPanel addressPanel;
private JPanel statePanel;
private JPanel stateANDTextPanel;
private JPanel zipcodePanel;
private JPanel phoneofficePanel;
private JPanel phonePanel;
private JPanel zipANDphonePanel;
private JPanel codePanel;
private JPanel officephonePanel;
private JPanel emailaddressPanel;
private JPanel genderPanel;
private JPanel genderANDemailPanel;
private JPanel dateofbirthPanel;
private JPanel dateofbirthTextPanel;
private JPanel monthdayyearPanel;
private JPanel birthPanel;
private JPanel nameOrderLabelPanel;
private JPanel citizenstatusPanel;
private JPanel continePanel;

private JPanel twelvePanels;

private Font font, fontGDP;

private JComboBox boxForSchoolsComboBox, graduateDegreeProgramComboBox,stateComboBox,citizenstatusComboBox;




private String graduateDegreePrograms[] = {"Aeronautics-Astonautics", "Earth Science","Applied Physics ", "Biochemistry", "Education", "Biosciences", "Humanities and Sciences", "Engineering and Applied Sciences", "Architecture", "Law", "Nursing", "Journalism"};
private String school[] = {"Engineering", "Medicine","Law", "Social Sciences", "Humanities", "Education","Sciences"};
private String states[] = {"ABIA","ADAMAWA","AKWA-IBOM","ANAMBRA","BAUCHI","BAYELSA","BENUE","BORNO","CROSS RIVER","DELTA","EBONYI","EDO","EKITI","ENUGU","GOMBE","IMO","JIGAWA","KADUNA","KANO","KATINSA","KEBBI","KOGI","KWARA","LAGOS","NASSARAWA","NIGER","OGUN","ONDO","OSUN","OYO","PLATEAU","RIVERS","SOKOTO","TARABA","YOBE","ZAMFARA","ABUJA (F.C.T)"};
private String citizen[] = {"U.S.CITIZEN","U.S.PERMANENT RESIDENT","NOT A U.S.CITIZEN","DECLINE TO STATE"};
/** Declaring a constructor. */
public Form()
{
//Set the title of the frame.
super.setTitle("Application Form");

font = new Font("Roman", Font.BOLD, 15);
fontGDP = new Font("Tahoma", Font.PLAIN,12);

//Initializing the applicationFormLabel.
applicationFormLabel = new JLabel("APPLICATION FORM");
applicationFormLabel.setFont(font);
applicationFormLabel.setForeground(Color.black);
applicationFormLabel.setVisible(true);
applicationFormPanel = new JPanel();
applicationFormPanel.add(applicationFormLabel);

//Initializing the applyingForLabel.
applyingForLabel = new JLabel("APPLYING FOR:");
applyingForLabel.setFont(font);
applyingForLabel.setForeground(Color.BLACK);
applyingForLabel.setVisible(true);
applyingForPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
applyingForPanel.add(applyingForLabel);

// Initializing the graduationDegreeProgramLabel
graduationDegreeProgramLabel = new JLabel("Graduation Degree Program:");
graduationDegreeProgramLabel.setFont(fontGDP);
graduationDegreeProgramLabel.setForeground(Color.BLACK);
graduationDegreeProgramLabel.setVisible(true);

// Initializing boxForSchoolsComboBox
boxForSchoolsComboBox = new JComboBox();
for(int count = 0; count <= 6; count++)
{
boxForSchoolsComboBox.addItem(school[count]);
}
boxForSchoolsComboBox.setMaximumRowCount(3);
boxForSchoolsComboBox.isEditable();
boxForSchoolsComboBox.setVisible(true);

// Initializing graduateDegreeProgramComboBox
graduateDegreeProgramComboBox = new JComboBox();
for(int count1 = 0; count1 <= 11; count1++)
{
graduateDegreeProgramComboBox.addItem(graduateDegreePrograms[count1]);
}
graduateDegreeProgramComboBox.setMaximumRowCount(4);
graduateDegreeProgramComboBox.isEditable();
graduateDegreeProgramComboBox.setVisible(true);

// Initializing schoolLabel
schoolLabel = new JLabel("School:");
schoolLabel.setFont(fontGDP);
schoolLabel.setForeground(Color.BLACK);
schoolLabel.setVisible(true);


// Initializing the schoolPanel
schoolPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
schoolPanel.add( schoolLabel);
schoolPanel.add(boxForSchoolsComboBox);

// Initializing graduationDegreeProgramLabel
graduationDegreeProgramLabel = new JLabel("Graduate Degree Program:");
graduationDegreeProgramLabel.setFont(fontGDP);
graduationDegreeProgramLabel.setForeground(Color.BLACK);
graduationDegreeProgramLabel.setVisible(true);

// Initializing the graduationDegreeProgramPanel
graduationDegreeProgramPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
graduationDegreeProgramPanel.add( graduationDegreeProgramLabel);
graduationDegreeProgramPanel.add(graduateDegreeProgramComboBox);


//Initializing the personalDetailsLabel
personalDetailsLabel = new JLabel("***************PERSONAL DETAILS:*******************");
personalDetailsLabel.setFont(font);
personalDetailsLabel.setForeground(Color.BLUE);
personalDetailsLabel.setVisible(true);

//Initializing the personalDetailsPanel
personalDetailsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
personalDetailsPanel.add(personalDetailsLabel);
personalDetailsPanel.setVisible(true);

//Initializing the nameText
nameText = new JTextField(45);
nameText.setFont(fontGDP);
nameText.setForeground(Color.BLACK);
nameText.setVisible(true);

//Initializing the nameLabel
nameLabel = new JLabel("NAME:");
nameLabel.setFont(fontGDP);
nameLabel.setForeground(Color.BLACK);
nameLabel.setVisible(true);

//Initializing the namePanel
namePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
namePanel.add(nameLabel);
namePanel.setVisible(true);


//Initializing the nameOrderLabel
nameOrderLabel = new JLabel(" FIRSTNAME MIDDLENAME LASTNAME");
nameOrderLabel.setFont(fontGDP);
nameOrderLabel.setForeground(Color.BLACK);
nameOrderLabel.setVisible(true);


//Initializing the nameTextPanel
nameTextPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
nameTextPanel.add(nameText);
nameTextPanel.setVisible(true);


//Initializing the nameOrderLabelPanel
nameOrderLabelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
nameOrderLabelPanel.add(nameOrderLabel);;
nameOrderLabelPanel.setVisible(true);

//Initializing the addressLabel
addressLabel = new JLabel("ADDRESS:");
addressLabel.setFont(fontGDP);
addressLabel.setForeground(Color.BLACK);
addressLabel.setVisible(true);


//Initializing the addressText
addressText = new JTextField(15);
addressText.setFont(fontGDP);
addressText.setForeground(Color.BLACK);
addressText.setVisible(true);

//Initializing the cityLabel
cityLabel = new JLabel(" CITY:");
cityLabel.setFont(fontGDP);
cityLabel.setForeground(Color.BLACK);
cityLabel.setVisible(true);

//Initializing the cityText
cityText = new JTextField(15);
cityText.setFont(fontGDP);
cityText.setForeground(Color.BLACK);
cityText.setVisible(true);



//Initializing the addressPanel
addressPanel= new JPanel(new FlowLayout(FlowLayout.LEFT));
addressPanel.add(addressLabel);
addressPanel.add(addressText);
addressPanel.add(cityLabel);
addressPanel.add(cityText);
addressPanel.setVisible(true);

//Initializing the stateLabel
stateLabel = new JLabel("STATES IN NIGERIA:");
stateLabel.setFont(fontGDP);
stateLabel.setForeground(Color.BLACK);
stateLabel.setVisible(true);

// Initializing stateComboBox
stateComboBox = new JComboBox();
for(int count1 = 0; count1 <= 36; count1++)
{
stateComboBox.addItem(states[count1]);
}
stateComboBox.setMaximumRowCount(5);
stateComboBox.isEditable();
stateComboBox.setVisible(true);

//Initializing the OtherstatesLabel
OtherstatesLabel = new JLabel(" ELSE STATE:");
OtherstatesLabel.setFont(fontGDP);
OtherstatesLabel.setForeground(Color.BLACK);
OtherstatesLabel.setVisible(true);

//Initializing the stateText
statetext = new JTextField(15);
statetext.setFont(fontGDP);
statetext.setForeground(Color.BLACK);
statetext.setVisible(true);

//Initializing the statePanel
statePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
statePanel.add(stateLabel);
statePanel.add(stateComboBox);
statePanel.add(OtherstatesLabel);
statePanel.add(statetext);
statePanel.setVisible(true);

//Initializing the stateANDTextPanel
//stateANDTextPanel = new JPanel(new GridLayout(2, 5, 0, 0));
//stateANDTextPanel.add(addressPanel);
//stateANDTextPanel.add(statePanel);
//stateANDTextPanel.setVisible(true);

//Initializing the zipcodeLabel
zipcodeLabel = new JLabel("ZIP CODE:");
zipcodeLabel.setFont(fontGDP);
zipcodeLabel.setForeground(Color.BLACK);
zipcodeLabel.setVisible(true);


//Initializing the zipcodeText
zipcodeText = new JTextField(15);
zipcodeText.setFont(fontGDP);
zipcodeText.setForeground(Color.BLACK);
zipcodeText.setVisible(true);

//Initializing the countryLabel
countryLabel = new JLabel(" COUNTRY");
countryLabel.setFont(fontGDP);
countryLabel.setForeground(Color.BLACK);
countryLabel.setVisible(true);


//Initializing the countryText
countryText = new JTextField(15);
countryText.setFont(fontGDP);
countryText.setForeground(Color.BLACK);
countryText.setVisible(true);

//Initializing the zipcodePanel
zipcodePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
zipcodePanel.add(zipcodeLabel);
zipcodePanel.add(zipcodeText);
zipcodePanel.add(countryLabel);
zipcodePanel.add(countryText);
zipcodePanel.setVisible(true);

//Initializing the phoneLabel
phoneLabel = new JLabel("PHONE (RESIDENCE):");
phoneLabel.setFont(fontGDP);
phoneLabel.setForeground(Color.BLACK);
phoneLabel.setVisible(true);

//Initializing the phonePanel
phonePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
phonePanel.add(phoneLabel);
phonePanel.setVisible(true);

//Initializing the zipANDphonePanel
//zipANDphonePanel = new JPanel(new GridLayout(2, 1, 0, 0));
//zipANDphonePanel.add(zipcodePanel);
//zipANDphonePanel.add(phonePanel);
//zipANDphonePanel.setVisible(true);

//Initializing the countrycodeLabel
countrycodeLabel = new JLabel("COUNTRY CODE:");
countrycodeLabel.setFont(fontGDP);
countrycodeLabel.setForeground(Color.BLACK);
countrycodeLabel.setVisible(true);

//Initializing the countrycodeText
countrycodeText = new JTextField(8);
countrycodeText.setFont(fontGDP);
countrycodeText.setForeground(Color.BLACK);
countrycodeText.setVisible(true);

//Initializing the areacodeLabel
areacodeLabel = new JLabel("AREA CODE:");
areacodeLabel.setFont(fontGDP);
areacodeLabel.setForeground(Color.BLACK);
areacodeLabel.setVisible(true);

//Initializing the areacodeText
areacodeText = new JTextField(8);
areacodeText.setFont(fontGDP);
areacodeText.setForeground(Color.BLACK);
areacodeText.setVisible(true);

//Initializing the phonenumberLabel
phonenumberLabel = new JLabel("PHONE NUMBER:");
phonenumberLabel.setFont(fontGDP);
phonenumberLabel.setForeground(Color.BLACK);
phonenumberLabel.setVisible(true);

//Initializing the phonenumberText
phonenumberText = new JTextField(8);
phonenumberText.setFont(fontGDP);
phonenumberText.setForeground(Color.BLACK);
phonenumberText.setVisible(true);

//Initializing the codePanel
codePanel= new JPanel(new FlowLayout(FlowLayout.LEFT));
codePanel.add(countrycodeLabel);
codePanel.add(countrycodeText);
codePanel.add(areacodeLabel);
codePanel.add(areacodeText);
codePanel.add(phonenumberLabel);
codePanel.add(phonenumberText);
codePanel.setVisible(true);

//Initializing the officephoneLabel
officephoneLabel = new JLabel("PHONE (OFFICE):");
officephoneLabel.setFont(fontGDP);
officephoneLabel.setForeground(Color.BLACK);
officephoneLabel.setVisible(true);

//Initializing the countrycodeLabel
countrycodeLabel = new JLabel("COUNTRY CODE:");
countrycodeLabel.setFont(fontGDP);
countrycodeLabel.setForeground(Color.BLACK);
countrycodeLabel.setVisible(true);

//Initializing the countrycodeText
countrycodeText = new JTextField(8);
countrycodeText.setFont(fontGDP);
countrycodeText.setForeground(Color.BLACK);
countrycodeText.setVisible(true);

//Initializing the areacodeLabel
areacodeLabel = new JLabel("AREA CODE:");
areacodeLabel.setFont(fontGDP);
areacodeLabel.setForeground(Color.BLACK);
areacodeLabel.setVisible(true);

//Initializing the areacodeText
areacodeText = new JTextField(8);
areacodeText.setFont(fontGDP);
areacodeText.setForeground(Color.BLACK);
areacodeText.setVisible(true);

//Initializing the phonenumberLabel
phonenumberLabel = new JLabel("PHONE NUMBER:");
phonenumberLabel.setFont(fontGDP);
phonenumberLabel.setForeground(Color.BLACK);
phonenumberLabel.setVisible(true);

//Initializing the phonenumberText
phonenumberText = new JTextField(8);
phonenumberText.setFont(fontGDP);
phonenumberText.setForeground(Color.BLACK);
phonenumberText.setVisible(true);

//Initializing the phoneofficePanel
phoneofficePanel= new JPanel(new FlowLayout(FlowLayout.LEFT));
phoneofficePanel.add(countrycodeLabel);
phoneofficePanel.add(countrycodeText);
phoneofficePanel.add(areacodeLabel);
phoneofficePanel.add(areacodeText);
phoneofficePanel.add(phonenumberLabel);
phoneofficePanel.add(phonenumberText);
phoneofficePanel.setVisible(true);



//Initializing the officephonePanel
officephonePanel= new JPanel(new FlowLayout(FlowLayout.LEFT));
officephonePanel.add(officephoneLabel);
officephonePanel.setVisible(true);

//Initializing the emailaddressLabel
emailaddressLabel = new JLabel("E-MAIL ADDRESS:");
emailaddressLabel.setFont(fontGDP);
emailaddressLabel.setForeground(Color.BLACK);
emailaddressLabel.setVisible(true);

//Initializing the emailaddressText
emailaddressText = new JTextField(15);
emailaddressText.setFont(fontGDP);
emailaddressText.setForeground(Color.BLACK);
emailaddressText.setVisible(true);

//Initializing the emailaddressPanel
emailaddressPanel= new JPanel(new FlowLayout(FlowLayout.LEFT));
emailaddressPanel.add(emailaddressLabel);
emailaddressPanel.add(emailaddressText);

//Initializing the genderLabel
genderLabel = new JLabel("GENDER:");
genderLabel.setFont(fontGDP);
genderLabel.setForeground(Color.BLACK);
genderLabel.setVisible(true);

//Initializing the maleButton
maleButton = new JRadioButton("MALE");
maleButton.setVisible(true);


//Initializing the femaleButton
femaleButton = new JRadioButton("FEMALE");
femaleButton.setVisible(true);


//Initializing the genderPanel
genderPanel= new JPanel(new FlowLayout(FlowLayout.LEFT));
genderPanel.add(genderLabel);
genderPanel.add( maleButton);
genderPanel.add( femaleButton);
genderPanel.setVisible(true);

//Initializing the dateofbirthLabel
dateofbirthLabel = new JLabel("DATE OF BIRTH:");
dateofbirthLabel.setFont(fontGDP);
dateofbirthLabel.setForeground(Color.BLACK);
dateofbirthLabel.setVisible(true);

//Initializing the dateofbirthText
dateofbirthText = new JTextField(45);
dateofbirthText.setFont(fontGDP);
dateofbirthText.setForeground(Color.BLACK);
dateofbirthText.setVisible(true);


//Initializing the monthdayyearLabel
monthdayyearLabel = new JLabel(" MONTH / DAY / YEAR:");
monthdayyearLabel.setFont(fontGDP);
monthdayyearLabel.setForeground(Color.BLACK);
monthdayyearLabel.setVisible(true);

// Initializing the dateofbirthPanel
dateofbirthPanel= new JPanel(new FlowLayout(FlowLayout.LEFT));
dateofbirthPanel.add(dateofbirthLabel);
dateofbirthPanel.setVisible(true);

// Initializing the dateofbirthTextPanel
dateofbirthTextPanel= new JPanel(new FlowLayout(FlowLayout.LEFT));
dateofbirthTextPanel.add(dateofbirthText);
//dateofbirthTextPanel.add(monthdayyearLabel);
dateofbirthTextPanel.setVisible(true);


// Initializing the monthdayyearPanel
monthdayyearPanel= new JPanel(new FlowLayout(FlowLayout.LEFT));
monthdayyearPanel.add(monthdayyearLabel);
monthdayyearPanel.setVisible(true);


//Initializing the citizenstatusLabel
citizenstatusLabel = new JLabel("CITIZENSHIP STATUS:");
citizenstatusLabel.setFont(fontGDP);
citizenstatusLabel.setForeground(Color.BLACK);
citizenstatusLabel.setVisible(true);

// Initializing citizenstatusComboBox
citizenstatusComboBox = new JComboBox();
for(int count = 0; count <= 3; count++)
{
citizenstatusComboBox.addItem(citizen[count]);
}
citizenstatusComboBox.setMaximumRowCount(2);
citizenstatusComboBox.isEditable();
citizenstatusComboBox.setVisible(true);

// Initializing the citizenstatusPanel
citizenstatusPanel= new JPanel(new FlowLayout(FlowLayout.LEFT));
citizenstatusPanel.add(citizenstatusLabel);
citizenstatusPanel.add(citizenstatusComboBox);
citizenstatusPanel.setVisible(true);

//Initializing the continueButton
continueButton = new JButton("PLEASE PRESS THE CONTINUE BUTTON TO DISPLAY THE QUALIFICATION DETAILS FORM......");
continueButton.setVisible(true);

//Initializing the continePanel
continePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
continePanel.add(continueButton);

Form1 form1 = new Form1();

ButtonHandler button = new ButtonHandler();
addressText.addActionListener(button);
continueButton.addActionListener(button);
//continueButton.addActionListener(form1);


twelvePanels= new JPanel(new GridLayout(24,22,0,0));
twelvePanels.add(applicationFormPanel);
twelvePanels.add(applyingForPanel);
twelvePanels.add(schoolPanel);
twelvePanels.add(graduationDegreeProgramPanel);
twelvePanels.add(personalDetailsPanel);
twelvePanels.add(namePanel);
twelvePanels.add(nameTextPanel);
twelvePanels.add(nameOrderLabelPanel);
twelvePanels.add(addressPanel);
twelvePanels.add(statePanel);
twelvePanels.add(zipcodePanel);
twelvePanels.add(phonePanel);
twelvePanels.add(codePanel);
twelvePanels.add(officephonePanel);
twelvePanels.add(phoneofficePanel);
twelvePanels.add(emailaddressPanel);
twelvePanels.add(genderPanel);
twelvePanels.add(dateofbirthPanel);
twelvePanels.add(dateofbirthTextPanel);
twelvePanels.add(monthdayyearPanel);
twelvePanels.add(citizenstatusPanel);
twelvePanels.add(continePanel);


// scroll.setScrollPosition(1,1);

add(twelvePanels);


}

private class ButtonHandler implements ActionListener,Serializable {



public void actionPerformed(ActionEvent e) {

Form1 form1 = new Form1();


String x = "";
File file = new File("client.txt");

/**
try {
RandomAccessFile Rfile = new RandomAccessFile("client.txt","rw");
long n = 10;
Rfile.seek(n);
} catch(FileNotFoundException j){}catch(IOException nb){}
*/

try {
FormLogic logic = new FormLogic();


PrintWriter out = new PrintWriter(new FileWriter(file));
logic.setName(nameText.getText());
String schooldata = (String) boxForSchoolsComboBox.getSelectedItem();
String graduatedata = (String)graduateDegreeProgramComboBox.getSelectedItem();
String statedata = (String) stateComboBox.getSelectedItem();
String addressdata = addressText.getText();
String citydata = cityText.getText();
String statdata = statetext.getText();
String zipcodedata = zipcodeText.getText();
String countrycode = countryText.getText();
String countrycodedata = countrycodeText.getText();
String areacodedata = areacodeText.getText();
String phonenodata = phonenumberText.getText();
String emaildata = emailaddressText.getText();
String datebatedata = dateofbirthText.getText();
String citizendata =(String) citizenstatusComboBox.getSelectedItem();
boolean radiodata = maleButton.isSelected();

/**
out.println(schooldata);
out.println(graduatedata);
out.println(logic.getName());



out.println(addressdata);
out.println(citydata);
out.println(statdata);
out.println(zipcodedata);
out.println(countrycode);
out.println(countrycodedata);
out.println(areacodedata);
out.println(phonenodata);
out.println(emaildata);
out.println(datebatedata);
if(radiodata == true) {
out.println("MALE");
}
else {out.println("FEMALE");}


out.close();
*/
RandomAccessFile Rfile = new RandomAccessFile("client.txt","rws");

long n =30;
n++;

Rfile.seek(file.length());
Rfile.seek(n);
Rfile.writeBytes(addressdata);

long m =20;
m++;
Rfile.seek(file.lastModified());
Rfile.seek(file.length());
Rfile.writeBytes(citydata);
Rfile.seek(file.length());


Rfile.close();

}catch (IOException e1){
System.out.print("error opening file");
}

//this.launch();

}


}

public static void main(String a[])
{
Form form = new Form();

form.setDefaultCloseOperation(EXIT_ON_CLOSE);

form.setSize(700,900);
form.setVisible(true);
form.setLocation(100, 200);
form.setResizable(false);

}
}
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Is there a question in there somewhere? Most of the code seems to be GUI code that has nothing to do with writing to a text file anyway.

Nobody is going to read through all that, by the way - it's way too much code, and you didn't UseCodeTags.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2204
    
    7
Post your SSCCE that demonstrates the problem.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: writing to text files