My environment:
Applet is in Apache2(redhat9),
Servlet is supported by Tomacat4.1.30 From website, Applet sends a filename to servlet, servlet reads this file line by line (each line contains three data, like 3.45 4.56 -1.23), and change each line to a data array, then send the data array back to Applet by serialized object and post method.
Problem: the applet got the error:java.io.EOFException
If servlet only reads line(inBuff.readLine),comments the part that converts each line to the data array(see my code below), no error. If adding this part, get the above error. Why? Is there any class or method not supported by
Tomcat servlet in my code? Thansk for any help!!
Servlet side code to read the file:
void readdata (long arg5){ /**arg5 is the file name from applet**/
char[] tempchar={'0','0','0','0','0','0','0'};
File ff=new File(filepath+Long.toString(arg5));
/******begin reading data into the float array channel********/
try{
if(ff.exists()){
try{
BufferedReader inBuff=new BufferedReader(new FileReader(filepath+Long.toString(arg5)));
inBuff.readLine();//read the first line of DAQ file
for(int i=0;i<datanum;i++){
String temp=inBuff.readLine();
int k=0,m=0;
/***the part to conver each line to the data array***/
//for(int j=0;j<temp.length();j++){
//if(temp.charAt(j)!=' '&&temp.charAt(j)!='\t'){
//tempchar[k]=temp.charAt(j);
//k++;
//if(j==temp.length()-1){
//String s=String.copyValueOf(tempchar);
//float f=Float.parseFloat(s);
//channel3[i][m]=f;
//channel3[i][m]=0;
//}
//}
//else{
//String s=String.copyValueOf(tempchar);
//float f=Float.parseFloat(s);
//channel3[i][m]=f;
//channel3[i][m]=0;
//m++;k=0;
//tempchar[6]='0';
//}
//}
}
inBuff.close();
}catch(FileNotFoundException e)
{df.servleterror2=true;df.servleterrormessage2=e.toString();}
catch(IOException e)
{df.servleterror2=true;df.servleterrormessage2=e.toString();}
}
else{
for(int p=0;p<channelnum3;p++)
for(int q=0;q<datanum;q++)
channel3[q][p]=0;
}
}catch(SecurityException e)
{df.servleterror2=true;df.servleterrormessage2=e.toString();}
}/****end of readdata*****/