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:
parent
64de18a629
commit
9282aca9cf
|
|
@ -14,9 +14,11 @@
|
||||||
package org.adempiere.webui.editor;
|
package org.adempiere.webui.editor;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.webui.component.FilenameBox;
|
import org.adempiere.webui.component.FilenameBox;
|
||||||
|
|
@ -133,7 +135,21 @@ public class WFilenameEditor extends WEditor
|
||||||
fileName = tempFile.getAbsolutePath();
|
fileName = tempFile.getAbsolutePath();
|
||||||
|
|
||||||
fos = new FileOutputStream(tempFile);
|
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.flush();
|
||||||
fos.close();
|
fos.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue