deleting lines from a file
<p>I need to delete certain lines from a file, the file is a list of contacts that I read in from a file into my GUI.  When I get to the contact I want to delete, my program should delete the contact from the file.  I've tried to do this, but it is not working.</p>

<p>Here is the code I'm currently using:</p>

<pre><code>String temp=txtname.getText();
for (Contact Contact:contacts)
{
    if (temp.equals(Contact.getname()));
    {
        txtname.setText("");
        txtsurname.setText("");
        txtphone.setText("");
        txtmobile.setText("");
        txtaddress.setText("");
        txtpostcode.setText("");
        contacts.remove(Contact);
        contacts.remove(Contact);
        contacts.remove(Contact);
        contacts.remove(Contact);
        contacts.remove(Contact);
        contacts.remove(Contact);
    }
}
</code></pre>

<p>My contact class is:</p>

<pre><code>public class Contact {

    static void add(String text) {
    }
public String name;
public String surname;
public String phone;
public String mobile;
public String address;
public String postcode;

public Contact(){}

public Contact(String name, String surname, String phone,
                   String mobile, String address, String postcode)
    {
 this.name = name;
 this.surname = surname;
 this.phone = phone;
 this.mobile = mobile;
 this.address = address; 
 this.postcode = postcode; 
}

    public String getname()
    {
        return this.name;
    }
    public String getsurname()
    {
        return this.surname;
    }
    public String getphone()
    {
        return this.phone;
    }
    public String getmobile()
    {
        return this.mobile;
    }
    public String getaddress()
    {
        return this.address;
    }
    public String getpostcode()
    {
        return this.postcode;
    }

    public void setname(String name)
    {
        this.name = name;
    }
    public void setsurname(String surname)
    {
        this.surname = surname;
    }
    public void setphone(String phone)
    {
         this.phone = phone;
    }
    public void setmobile(String mobile)
    {
         this.mobile = mobile;
    }
    public void setaddress(String address)
    {
         this.address = address;
    }
     public void setpostcode(String postcode)
    {
         this.postcode = postcode;
    }
}
</code></pre>

<p>I'm guessing it deletes it from the arraylist, but I'm not sure how the program knows what to delete from the file.</p>

<p>Thanks.</p>
