Android에서 애플리케이션을 만들었으며이 애플리케이션은 파일에 활동을 기록합니다. .zip 파일을 저장할 수 있도록 파일을 내보내는 옵션이 있습니다. .zip에 추가 할 파일이 둘 이상 있으면 다음 오류가 발생합니다.Android 2.3 일반 목적 플래그가있는 ZIP 문제
(범용 플래그 - 로컬 : 808 16 진수 중앙 : 8hex). 로컬 및 중앙 GPFlags 값이 일치하지 않습니다.
이것은 Android 2.3 및 winzip 또는 7zip을 사용하는 경우에만 발생합니다. Windows 탐색기 나 Winrar를 사용하여이 문제를 우회 할 수 있지만 문제를 해결하고 피하고 싶습니다.
Android 2.2 기기에서 동일한 애플리케이션을 사용하는 경우는 발생하지 않습니다.
전 주위를 수색하여 암호화에 대한 의견을 찾았지만 암호화하지는 않았습니다. 또한 특정 라이브러리 등을 업데이트하는 것에 대한 몇 가지 의견을 발견했지만 Android sdk 11 및 java jdk 1.6.0_25를 사용하고 있습니다.
나는 같은 결과
int count = log_.getLogFileList(files_);
if (count > 0)
{
String inFileName;
File inFile;
String phoneNumLast =OsmoService.getAccountString(OsmoService.context).substring(6);
long date = files_.get(count - 1).lastModified();
SimpleDateFormat formatter = new SimpleDateFormat("MMddHHmmss");
String outdt = new String(formatter.format(new Date(date)));
String outFileName = new String("Dir Name" + "//" + "PREFIX" + "_" + outdt + ZIP_SUFFIX);
File outFile = new File(outFileName);
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(outFile));
BufferedOutputStream outBS = new BufferedOutputStream(zos, 8192);
for (int idx = (count - 1); (idx >= 0) && !isCancelled(); idx--)
{
inFile = files_.get(idx);
BufferedReader inBR = new BufferedReader(new FileReader(inFile), 8192);
inFileName = inFile.getName();
Log.v(LOG_TAG, "MailLogFiles - Zipping " + inFileName);
zos.putNextEntry(new ZipEntry(inFileName));
int zix;
while ((zix = inBR.read()) != -1)
outBS.write(zix);
outBS.flush();
zos.closeEntry();
inBR.close();
}
outBS.close();
와 2 개 개의 다른 코드를 시도하고이
public static void compressFileList(String[] inFiles, String outFile)
throws IOException
{
ZipOutputStream zos = new ZipOutputStream(
new BufferedOutputStream(new FileOutputStream(outFile)));
byte data[] = new byte[2048];
for (int i = 0; i < inFiles.length; i++)
{
BufferedInputStream in = new BufferedInputStream(new FileInputStream(inFiles[i]));
zos.putNextEntry(new ZipEntry(inFiles[i]));
int count;
while((count = in.read(data, 0, data.length)) != -1)
zos.write(data, 0, count);
zos.closeEntry();
in.close();
}
zos.close();
}