public String prefixZip(Object obj) throws FrameException {
String str = "";
PrintWriter dataos = null;
String strPath = ServerInfo.getDownloadPath();
try
{
File file = null;
file = new File(strPath);
file.mkdirs();
Date dd = new Date();
long strD = dd.getTime();
// rvo.setretVO(PREFIXFILE + String.valueOf(strD)+".zip");
//创建文件名
str = PREFIXFILE + String.valueOf(strD) + ".zip";
StringBuffer strFullPath = new StringBuffer(strPath);
strFullPath.append(System.getProperty("file.separator"));
strFullPath.append(PREFIXFILE);
strFullPath.append(String.valueOf(strD));
strFullPath.append(".zip");
file = new File(strFullPath.toString());
TraceService.debug(LogConstants.DEPLOY,"获取压缩路径:" + strFullPath.toString());
//读取文件
ZipOutputStream zipos = new ZipOutputStream(new FileOutputStream(file));
zipos.setMethod(ZipOutputStream.DEFLATED);
zipos.putNextEntry(new ZipEntry("prefix.txt"));
dataos = new PrintWriter(zipos);
//开始处理Object,对object进行解析
if (obj instanceof MiscPrefixVO)
{
TraceService.debug(LogConstants.DEPLOY, "压缩对象为MiscPrefixVO");
dataos.print( sysCodeString(((MiscPrefixVO) obj).toString()));
}
else if (obj instanceof ArrayList)
{
int lLen = ( (ArrayList) obj).size();
TraceService.debug(LogConstants.DEPLOY,"压缩对象为ArrayList ,长度为" + lLen);
for (int i = 0; i < lLen; i++)
{
MiscPrefixVO mVO = (MiscPrefixVO) ( (ArrayList) obj).get(i);
dataos.print(sysCodeString(mVO.toString()));
dataos.flush();
}
}
dataos.close();
dataos = null;
}
catch (FileNotFoundException fne) {
if (dataos != null) {
try {
dataos.close();
}
catch (Exception e) {
}
dataos = null;
}
throw new FrameException(OAMErrorCodeConst._EC_PREFIX_ZIP_FAIL,
"压缩文件错误!" + fne.toString());
}
catch (IOException ioe) {
if (dataos != null) {
try {
dataos.close();
}
catch (Exception e) {
}
dataos = null;
}
throw new FrameException(OAMErrorCodeConst._EC_PREFIX_ZIP_FAIL,
"生成压缩文件失败!" + ioe.toString());
}
return str;
}
String str = "";
PrintWriter dataos = null;
String strPath = ServerInfo.getDownloadPath();
try
{
File file = null;
file = new File(strPath);
file.mkdirs();
Date dd = new Date();
long strD = dd.getTime();
// rvo.setretVO(PREFIXFILE + String.valueOf(strD)+".zip");
//创建文件名
str = PREFIXFILE + String.valueOf(strD) + ".zip";
StringBuffer strFullPath = new StringBuffer(strPath);
strFullPath.append(System.getProperty("file.separator"));
strFullPath.append(PREFIXFILE);
strFullPath.append(String.valueOf(strD));
strFullPath.append(".zip");
file = new File(strFullPath.toString());
TraceService.debug(LogConstants.DEPLOY,"获取压缩路径:" + strFullPath.toString());
//读取文件
ZipOutputStream zipos = new ZipOutputStream(new FileOutputStream(file));
zipos.setMethod(ZipOutputStream.DEFLATED);
zipos.putNextEntry(new ZipEntry("prefix.txt"));
dataos = new PrintWriter(zipos);
//开始处理Object,对object进行解析
if (obj instanceof MiscPrefixVO)
{
TraceService.debug(LogConstants.DEPLOY, "压缩对象为MiscPrefixVO");
dataos.print( sysCodeString(((MiscPrefixVO) obj).toString()));
}
else if (obj instanceof ArrayList)
{
int lLen = ( (ArrayList) obj).size();
TraceService.debug(LogConstants.DEPLOY,"压缩对象为ArrayList ,长度为" + lLen);
for (int i = 0; i < lLen; i++)
{
MiscPrefixVO mVO = (MiscPrefixVO) ( (ArrayList) obj).get(i);
dataos.print(sysCodeString(mVO.toString()));
dataos.flush();
}
}
dataos.close();
dataos = null;
}
catch (FileNotFoundException fne) {
if (dataos != null) {
try {
dataos.close();
}
catch (Exception e) {
}
dataos = null;
}
throw new FrameException(OAMErrorCodeConst._EC_PREFIX_ZIP_FAIL,
"压缩文件错误!" + fne.toString());
}
catch (IOException ioe) {
if (dataos != null) {
try {
dataos.close();
}
catch (Exception e) {
}
dataos = null;
}
throw new FrameException(OAMErrorCodeConst._EC_PREFIX_ZIP_FAIL,
"生成压缩文件失败!" + ioe.toString());
}
return str;
}