Problems with signed Applet for File Download under JRE 1.4 (works with 1.3

Dear all,

i encountered a very strange behaviour with JRE 1.4x. A signed applet used for file download worked on all platforms (Windows NT, 2000 and XP wth/wthout SP...) until I installed JRE 1.4.x (1.4.1 or 1.4.2)

I get an EOFException when downloading binary files (for ASCII it works fine) when trying to readByte() from a DataInputStream. But not immideately, but after x bytes in the while-loop. Security is fine (I know there have been changes to that in jre 1.4, the applet itself can be started an runs with ASCII files for transfer)

Does anyone know, what has changed in jre1.4.

As I said, it works fine under jre 1.3.x

The relevant code is below: byte bt = dis.readByte(); causes the error

try{

// Get URL from Server

URL uFile = new URL(sFilename);

sThisURLFile = uFile.getFile();

Integer inte = new Integer(i);

//open input stream for the file on server

DataInputStream dis = new DataInputStream(new BufferedInputStream

(uFile.openConnection().getInputStream()));

//open output stream for the file on local drive

String sFilenameOnly = sThisURLFile.substring(sThisURLFile.lastIndexOf('/')+1);

int iDotPos = sFilenameOnly.lastIndexOf(".");

String sExt;

if (iDotPos > 0) {

sExt= sFilenameOnly.substring(iDotPos);

} else {

sExt = "";

}

File fileOut = new File(sDownloadDir + sThisURLFile.substring(sThisURLFile.lastIndexOf('/')+1) );

DataOutputStream dos = new DataOutputStream(new

BufferedOutputStream(new FileOutputStream(fileOut)));

//read one byte from input stream, and write that byte to output stream

long nByte = 0;

int iCnt = 0;

iFilesizeDone ++;

while (nByte < iFilesize){

String sErrPs = new String();

try{

sErrPs = "00";

byte bt = dis.readByte();

sErrPs = "01";

dos.writeByte(bt);

} catch (EOFException ee)

{

System.err.println("internal EOFException: " + ee.getMessage());

System.out.println("Error Filesize is " +nByte +" of " +iFilesize + "" + sErrPs);

break;

}

nByte++;

iFilesizeDone ++;

iCnt ++;

if(iCnt >= 10240) {

ShowProgress(nByte, iFilesize, iFilesizeDone, iFilesizeTotal); // repaint does not work during init-procedure

iCnt = 0;

}

}

line = "Progress: Total: " + ((iFilesizeDone*100)/iFilesizeTotal) + " perc, " + iFilesizeTotal/1024 +" kbytes" ;

labLine.setText(line);

//dos.flush(); // improves Client performance (Agent-Call!)

dis.close();

dos.close();

}// End try

catch (EOFException ee)

{

System.err.println("EOFException: " + ee.getMessage()e);

}

catch (SecurityException se)

{

System.err.println("SecurityException: " + se.getMessage());

}

catch (IOException ioe)

{

System.err.println("IOException: " + ioe.getMessage());

}

[2991 byte] By [mrittmeia] at [2007-9-29 19:35:40]
# 1

perhaps they've changed something with the file blocking.

btw, you should try to use something like this

DataInputStream dis = new DataInputStream(is);

byte[] buffer=new byte[8192];

int numBytesRead;

while ( dis.available()>0 ) {

numBytesRead = dis.read(buffer);

}

hamstaa at 2007-7-15 20:58:34 > top of Java-index,Security,Signed Applets...