Java Android 2.3通用标志的ZIP问题
我在Android上制作了一个应用程序,这个应用程序将活动记录到文件中。我可以选择导出文件,因此我将文件保存在.zip中。如果有多个文件要添加到.zip中,则会出现以下错误 (通用标志-本地:808十六进制中央:8十六进制)。 本地和中心GPFlags值不匹配 这只会发生在Android 2.3和使用winzip或7zip时。我可以使用windows资源管理器或winrar绕过此问题,但我希望解决此问题,而不是避免它 在Android 2.2设备上使用相同的应用程序不会发生这种情况 我四处搜索,找到了一些关于加密的评论,但我没有加密任何东西。我还发现了一些关于更新某些库之类的评论,但我使用的是Android sdk 11和java jdk 1.6.025 我尝试了两种不同的代码,结果相同Java Android 2.3通用标志的ZIP问题,java,android,file,zipfile,android-2.3-gingerbread,Java,Android,File,Zipfile,Android 2.3 Gingerbread,我在Android上制作了一个应用程序,这个应用程序将活动记录到文件中。我可以选择导出文件,因此我将文件保存在.zip中。如果有多个文件要添加到.zip中,则会出现以下错误 (通用标志-本地:808十六进制中央:8十六进制)。 本地和中心GPFlags值不匹配 这只会发生在Android 2.3和使用winzip或7zip时。我可以使用windows资源管理器或winrar绕过此问题,但我希望解决此问题,而不是避免它 在Android 2.2设备上使用相同的应用程序不会发生这种情况 我四处搜索,
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();
还有这个
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();
}
公共静态void compressFileList(字符串[]填充,字符串输出文件)
抛出IOException
{
ZipoutStream zos=新ZipoutStream(
新的BufferedOutputStream(新的FileOutputStream(outFile));
字节数据[]=新字节[2048];
对于(int i=0;i
我认为这是由一个报告的错误引起的,该错误将在冰淇淋三明治中修复: