When I using ZipOutputStream and ZipEntry to compress some files into one zip file, I found the Arabic Files Names were corrupted when I decompress the zip file, although the English files names are correct .
e.g. شركة انظمة الاتصالات والحلول الأمنية المحدودة
Instead of: بيان المشاريع السابقة
Java Version : 1.6
My code (Start point convertToZip) :
public void convertToZip(OAApplicationModule oaapplicationmodule,Number AuctionHeaderID)
{
OADBTransaction oadbtransaction = oaapplicationmodule.getOADBTransaction();
OracleResultSet rsZippedEmptyBlob= PrepareNewZipProcess ( oadbtransaction , AuctionHeaderID) ;
try
{
if ( !rsZippedEmptyBlob.next() )
{
return ;
}
OracleResultSet rLoopSourceBlob = (OracleResultSet)GetBlobResultSetFromRFX ( oadbtransaction , AuctionHeaderID ) ;
BLOB zippedEmptyBlob = rsZippedEmptyBlob.getBLOB(1);
ZipOutputStream zosFinal = new ZipOutputStream ( zippedEmptyBlob.getBinaryOutputStream());
zosFinal.setMethod(ZipOutputStream.DEFLATED);
byte[] bytesArrayFromSourceBlob = new byte[1024];
while(rLoopSourceBlob.next())
{
BLOB sourceBlobFile = rLoopSourceBlob.getBLOB(1);
ZipEntry zippedSingleFileName = new ZipEntry( rLoopSourceBlob.getString(2) ) ;
zosFinal.putNextEntry(zippedSingleFileName);
int lengthRead ;
InputStream DocumentStream = sourceBlobFile.getBinaryStream();
while((lengthRead=DocumentStream.read(bytesArrayFromSourceBlob))>=0) //>0
{
zosFinal.write(bytesArrayFromSourceBlob,0,lengthRead);
}
sourceBlobFile.getBinaryStream().close();
zosFinal.closeEntry();
}
zosFinal.close();
oadbtransaction.commit();
}
catch ( Exception ex )
{
throw OAException.wrapperException(ex);
}
}