i'm still working on the property to let program. and it sort of works... its just when the user selects to delete a line from it it will delete it fine, but it will then duplicate all the items that where previously in it...
EG: My File looks like this to start with...
1. pe158ul,1,566
2. ln11ur,4,755
3. df336ty,77,800
then the user want to delete line 2 so they type in 1(because you have to enter 1 less than the actual number) and it then ends up looking like this
1. pe158ul,1,566
2. df336ty,77,800
3. pe158ul,1,566
4. ln11ur,4,755
5. df336ty,77,800
heres my code to do that bit... can anybody see why. I sure as hell cant...
if(i == 2)
{
try
{
System.out.println("\nEnter the line number of the property you wish to remove");
ln = Double.valueOf(br.readLine()).intValue();
BufferedReader br=new BufferedReader(new FileReader("properties.txt"));
String line=null;
while ((line=br.readLine()) != null)
{
String[] addy=line.split(",");
PropertyToLet ptl=new PropertyToLet(addy[0],addy[1],addy[2]);
v.addElement(ptl);
}
v.removeElementAt(ln);
PrintWriter outFile = new PrintWriter(new FileWriter("properties.txt"));
for (int i=0; i<v.size(); i++)
{
PropertyToLet obj = (PropertyToLet) (v.get(i));
outFile.println(obj.getpc() + "," + obj.gethn() + "," + obj.getmr());
}
outFile.close();
}
catch(ArrayIndexOutOfBoundsException aioobe)
{
System.out.println("An Error Has occurred");
}
catch(IOException ex)
{
ex.printStackTrace();
}
}