English 中文(简体)
法典Im是否正确?
原标题:Is the code I m using to make .zip files correct?

I m在C#至zip文档中使用这一代码。 我需要在安伯斯(java)开设这些档案:

String mp3Files = "E:\"; 
int TrimLength = mp3Files.ToString().Length;

byte[] obuffer;
string outPath = mp3Files + "\" + i + ".zip";
ZipOutputStream oZipStream = new ZipOutputStream(File.Create(outPath)); // create zip stream
oZipStream.SetLevel(9); // maximum compression

foreach (string Fil in ar) // for each file, generate a zipentry
{

    oZipEntry = new ZipEntry(Fil.Remove(0, TrimLength));
    oZipStream.PutNextEntry(oZipEntry);

    if (!Fil.EndsWith(@"/")) // if a file ends with  /  its a directory
    {
        ostream = File.OpenRead(Fil);
        obuffer = new byte[ostream.Length];
        ostream.Read(obuffer, 0, obuffer.Length);
        oZipStream.Write(obuffer, 0, obuffer.Length);
    }
}
oZipStream.Finish();
oZipStream.Close();

我在把这些档案摘录于java方面有问题,我希望确保问题从卷宗中解决。 j能够读一下这些zi子吗?

我只是试图通常使用赢利器制造,档案提取法也提出了同样的问题。

    String zipFile = Path + FileName;


            FileInputStream fin = new FileInputStream(zipFile);
            ZipInputStream zin = new ZipInputStream(fin);

            ZipEntry ze = null;
            while ((ze = zin.getNextEntry()) != null) {
                UnzipCounter++;
                if (ze.isDirectory()) {
                    dirChecker(ze.getName());
                } else {
                    FileOutputStream fout = new FileOutputStream(Path
                            + ze.getName());
                    while ((Unziplength = zin.read(Unzipbuffer)) > 0) {
                        fout.write(Unzipbuffer, 0, Unziplength);                    
                    }
                    zin.closeEntry();
                    fout.close();

                }

            }
            zin.close();
问题回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签