slopjong / eclipse-artifacts

PKGBUILD generator for eclipse plugins.
2 stars 0 forks source link

Writing data to a file with the given snippet, makes it corrupt #9

Open slopjong opened 12 years ago

slopjong commented 12 years ago

The following snippet writes the content of a QBuffer to a jar file but while the file size looks ok the jar file is corrupt.

// data is from the type QBuffer *
// fileName is from the type QString
data->open(QIODevice::ReadOnly);
QByteArray feature = data->readAll();
QFile jarfile;
jarfile.setFileName(fileName);
jarfile.open(QIODevice::WriteOnly);
QTextStream fout(&jarfile);
fout << feature << endl;
jarfile.close();

Both, file-roller and jar, could not extract the content. jar returned the following exception:

java.util.zip.ZipException: invalid code lengths set
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
    at java.util.zip.ZipInputStream.read(ZipInputStream.java:163)
    at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:109)
    at sun.tools.jar.Main.extractFile(Main.java:954)
    at sun.tools.jar.Main.extract(Main.java:870)
    at sun.tools.jar.Main.run(Main.java:260)
    at sun.tools.jar.Main.main(Main.java:1167)

Keywords