Applet File Access

Steven C. Oimoen (soimoen@afit.af.mil)
Wed, 4 Feb 1998 11:03:22 EST

Date: Wed, 4 Feb 1998 11:03:22 EST
From: "Steven C. Oimoen" <soimoen@afit.af.mil>
Subject: Applet File Access
To: java-security@web2.javasoft.com

To Whom It May Concern,

I thought I was successfully opening a file and reading in the
data to an array. I was then writing the array back out to
another file. The original file and the newly created output
file were identical. However, the values placed into the array
were garbage. I've enclosed the procedure and wondered if you
had any thoughts or ideas:

public void readFileData(){

int i;
int j;

try{
URL url_measure=new URL(getCodeBase(),file_name);

InputStream is_file= url_measure.openStream();

DataInputStream dis_file=new DataInputStream(new
BufferedInputStream(is_file));

DataOutputStream dos_file = new DataOutputStream(new
FileOutputStream("a:temp1.txt"));

for (i=0;i<(number_of_trains+number_of_wt_rows);i++){
for (j=0;j<number_of_measures;j++){
file_data_array[i][j]=(float)dis_file.readFloat();
System.out.println(file_data_array[i][j]);
dos_file.writeFloat(file_data_array[i][j]);
}
}
//dis_file.close();
dos_file.close();

}

catch (MalformedURLException me){
System.out.println("DataFileMalformedURLException:"+me);
}
catch (IOException ioe){
System.out.println("DataFileIOException: " +ioe);
}

}//end readFileData

I greatly appreciate any assistance.

Thanks,

Capt Steve Oimoen