Fix [ adempiere-ZK Web Client-2603511 ] Error loading text file

https://sourceforge.net/tracker2/?func=detail&atid=955896&aid=2603511&group_id=176962
This commit is contained in:
Carlos Ruiz 2009-02-15 21:22:03 +00:00
parent 64de18a629
commit 9282aca9cf
1 changed files with 17 additions and 1 deletions

View File

@ -14,9 +14,11 @@
package org.adempiere.webui.editor;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import org.adempiere.webui.component.FilenameBox;
@ -133,7 +135,21 @@ public class WFilenameEditor extends WEditor
fileName = tempFile.getAbsolutePath();
fos = new FileOutputStream(tempFile);
fos.write(file.getByteData());
byte[] bytes = null;
try {
bytes = file.getByteData();
}
catch ( IllegalStateException ise ) {
InputStream is = file.getStreamData();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[ 1000 ];
int byteread = 0;
while (( byteread=is.read(buf) )!=-1)
baos.write(buf,0,byteread);
bytes = baos.toByteArray();
}
fos.write(bytes);
fos.flush();
fos.close();
} catch (IOException e) {