Strange problem in java
Hi,
I have a following program , this program call aother classes .
my problem is that if I run loop to call the classe
for (int i =3;i<=4;i++), I get a strange error saying :
Classification accuracy = 100.0 %
error accuracy = 0.0 %
Accuracy = 100.0 %
Error rate = 0.0 %
java.io.FileNotFoundException: dataf\iris\TrainingData.txt (Access is denied)
But when I run for evry single iteration for example
for (int i =3;i<=3;i++),
There is no problem, I need 10 iteration for this code so, it is not cconvenient to everytime for every iteration I run the program again and chnage the loob for every single iteration to get correct results like this:
for (int i =1;i<=1;i++), :
run again
for (int i =2;i<=2;i++), :
run again
for (int i =3;i<=3;i++), :
........
until for (int i =10;i<=10;i++), :
This gives correct results but as I mentioned this is not good coding, is there anyway to avoid that I just run oncefor (int i =1;i<=10;i++), :
My code is attached under"
public class RunAllPrograms {
static double [] AccuracyCal = new double [10];
static double [] ErrorCal = new double [10];
public static void main(String[] args) throws IOException{
// TestKillProcess J= new TestKillProcess();
String Rel = JOptionPane.showInputDialog ("Enter Relation name : ");
for (int i =3;i<=4;i++){
RunAllPrograms Y = new RunAllPrograms();
Y.deleteFile ("dataf/"+Rel+"/ProftFileClassification.txt");
Y.deleteFile ("dataf/"+Rel+"/plength.txt");
Y.deleteFile ("dataf/"+Rel+"/pwidth.txt");
Y.deleteFile ("dataf/"+Rel+"/slength.txt");
Y.deleteFile ("dataf/"+Rel+"/swidth.txt");
Y.deleteFile ("dataf/"+Rel+"/TrainingData.txt");
Y.deleteFile ("dataf/"+Rel+"/TestingData.txt");
Feras_SplitTrainingAndTesting A = new Feras_SplitTrainingAndTesting();
SplitAtributes B = new SplitAtributes();
FerasPrgMain C = new FerasPrgMain();
Statistics D = new Statistics();
FerasID3 E = new FerasID3();
SortClassification F = new SortClassification();
Prototypes G = new Prototypes();
Proaftn3 H = new Proaftn3();
Accuracy I = new Accuracy();
A.Start1(Rel,i);
B.Start2(Rel);
C.Start3(Rel);
D.Start4(Rel);
E.Start5(Rel);
F.Start6(Rel);
G.Start7(Rel);
H.Start8(Rel);
I.Start9(Rel);
AccuracyCal[i-1] = I.AccuracyVal;
ErrorCal[i-1]= I.ErrorVal;
Write( i, AccuracyCal[i-1] );
System.out.println(" Accuracy = "+ I.AccuracyVal + " %");
System.out.println(" Error rate = "+ I.ErrorVal + " %");
}// end for
double sum1=0, sum2=0;
for ( int j= 0; j<AccuracyCal.length; j++) {
sum1 = sum1+ AccuracyCal[j];
sum2 = sum2+ ErrorCal[j];
}
System.out.println(" Average Accuracy = "+ sum1/AccuracyCal.length + " %");
System.out.println(" Average Error rate = "+ sum1/ErrorCal.length + " %");
}
public static void deleteFile (String DelFile )
{
File myFile = new File(DelFile);
try
{
myFile.delete();
// System.out.println("Successfully deleted " + myFile.toString());
}
catch (SecurityException e)
{
System.out.println("Caught security exception trying to delete file " + myFile.toString());
}
}
public static void Write( int x, double Results )throws IOException
{
DecimalFormat myDecFormat = new DecimalFormat("####.00");
File appending = new File("RessultsNow.txt"); // Prototype file name
FileWriter appendingW = new FileWriter(appending, true);
BufferedWriter StartAppend = new BufferedWriter(appendingW);
StartAppend.write(x+"\t"+Results);
StartAppend.newLine();
StartAppend.close();
}
}>

