Inconsitency in zipInputStream

hi
i'm trying to use java.util.zip API. here i see inconsistency while using ZipInputStream.read i.e it doesn't return the exact length for larger files.
in the following code, the value of entrySize(this value is acurate) and readCount (this value is wrong) doesn't match for larger files in the zip folder but smaller files (>12kb) doesn't have this issue ... as a result in the output , the data in the larger files are truncated.
any idea/solution?
long entrySize = entry1.getSize();
                         Debug.logInfo("entry size"+ entrySize);
                         byte[] data = null;
                         if(entrySize <= 0){
                              data = new byte[1024];
                         }else{
                              data = new byte[new Long(entrySize).intValue()];
                          int readCount = zipInputStream.read(data, 0, data.length);
                          docxOutFile.putNextEntry(new ZipEntry(entry1.getName()));
                          docxOutFile.write(data, 0, readCount);
                          docxOutFile.closeEntry();Edited by: sunnySide-LDC on Oct 30, 2008 4:18 PM

Where does it say that read() has to return the same length you asked for?
Try this:
int readCount;
while ((readCount = in.read(buffer)) > 0)
  out.write(buffer, 0, readCount);Works every time, for any buffer size > 0, and every kind of stream.

Similar Messages

  • Can't get from ServletInputStream to ZipInputStream

    Here's a problem that's been bothering me:
    I'm trying to set up an import program where I submit a .zip file via POST to a servlet.
    I can submit the .zip and read its binary data just fine. I can also open a zip file that's on the server and parse it contents via java.util.zip and ZipImputStream.
    For some reason though, I can't go from point A to Point B.
    // works
    FileInputStream fis = new FileInputStream( "_test.zip" );
    ZipInputStream zisImportArchive = new ZipInputStream( fis );
    // works
    ServletInputStream sis = request.getInputStream();
    // doesn't work
    ZipInputStream zisImportArchive = new ZipInputStream( sis );
    I don't get any errors, but out.println( zisImportArchive); always returns "null" when it's made from the ServletInputStream.
    Has anyone run into anything like this before?

    Change iTunes Store Country on an iDevice
    1. Tap Settings;
    2. Tap iTunes & App Stores;
    3. Tap View Apple ID;
    4. Enter your user name and password;
    5. Tap Country/Region;
    6. Tap Change Country/Region;
    7. Select the region where you will be located;
    8. Tap Done.
    Also, see How to Change Your iTunes Store Account Location | eHow.com.

  • Problem in unzipping a file : ZipInputStream

    Hi All,
    I am having some issues in unzipping a zip file using ZipInputStream.
    Following is the code :
    public class ZipInputStreamExample {
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              final int BUFFER = 2048;
              try {
                   ZipInputStream zip = new ZipInputStream(new BufferedInputStream(
                             new FileInputStream(
                                       "OBU4526 - Change to mobile services pages-1.zip")));
                   ZipEntry entry;
                   System.out.println("hello world");
                   while ((entry = zip.getNextEntry()) != null) {
                        System.out.println("Unzipping: " + entry);
                        int count;
                        byte[] data = new byte[BUFFER];
                        FileOutputStream fout = new FileOutputStream(entry.getName());
                        BufferedOutputStream buf = new BufferedOutputStream(fout,
                                  data.length);
                        while ((count = zip.read(data, 0, BUFFER)) != -1) {
                             buf.write(data, 0, count);
                        buf.flush();
                        buf.close();
                   zip.close();
              } catch (FileNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }Following is the exception which I am getting :
    hello world
    Unzipping: OBU4526 - Change to mobile services pages/css/
    java.io.FileNotFoundException: OBU4526 - Change to mobile services pages\css (The system cannot find the path specified)
         at java.io.FileOutputStream.open(Native Method)
         at java.io.FileOutputStream.<init>(Unknown Source)
         at java.io.FileOutputStream.<init>(Unknown Source)
         at com.example.io.ZipInputStreamExample.main(ZipInputStreamExample.java:37)Any problem with the code ? How could I solve this issue ? Do I need to create the directory structure (OBU4526 - Change to mobile services pages\css) ? Shouldn't the FileOutputStream create the structure if it isn't created. ?
    Any help would be appreciated.
    Thanks
    Siddharth

    ejp wrote:
    Delete that directory and try again.I did that and tried again. I refreshed and noticed that what is happening is that top level folder is being created but after that sub folders are not being created. It is not recognizing sub folders under the top level folders. Under the top level folder its directly making the file instead of making the folder. Following is the code snippet:
    while ((entry = zip.getNextEntry()) != null) {
                        System.out.println("Unzipping: " + entry);
                        int count;
                        new File(entry.getName()).getParentFile().mkdirs();
                        bos = new BufferedOutputStream(new FileOutputStream(entry.getName()));
                        while((count = zip.read(b, 0, BUFFER)) != -1){
                             bos.write(b, 0, count);
                   zip.closeEntry();
                   }Its also giving the following exception :
    Unzipping: OBU4526 - Change to mobile services pages/css/
    Unzipping: OBU4526 - Change to mobile services pages/css/discover-activate.css
    java.io.FileNotFoundException: OBU4526 - Change to mobile services pages\css\discover-activate.css (The system cannot find the path specified)
         at java.io.FileOutputStream.open(Native Method)
         at java.io.FileOutputStream.<init>(Unknown Source)
         at java.io.FileOutputStream.<init>(Unknown Source)
         at com.example.io.ZipInputStreamExample.main(ZipInputStreamExample.java:41)It has created the folder "OBU4526 - Change to mobile services pages" but not "css". Instead of creating the folder css its creating the file css. Instead it should create the folder "css" also and then create the file "discover-activate.css". I don't know why its giving this exception. :(
    By this exception I suppose its asking us to create the css folder also. I am correct.
    What's the resolution of this issue.?
    Please do help me in resolving this issue. Thanks in advance.

  • Zipfile and zipinputstream code

    Hi!
    I need to unzip something that is in a bytearrayoutputstream. Since zipfile and zipinputstream does not receive bytearrayoutputstream I thought of creating my own but I don't know how to do that. I need someone to help me with the code. I need a code not advice please.
    All I know is that it should extend to zipfile .
    Please help

    ** a simple unZIP tool
    ** ex.  java UnZip file.zip file1   to unzip file 1 from file.zip
    **      java UnZip file.zip         to unzip file.zip
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import java.text.*;
    class UnZip {
      public static void main(String args[]) throws IOException {
        InputStream in = new BufferedInputStream(new FileInputStream(args[0]));
        ZipInputStream zin = new ZipInputStream(in);
        ZipEntry e;
        while((e=zin.getNextEntry())!= null) {
          if (args.length > 1) {
            if (e.getName().equals(args[1])) {
               unzip(zin, args[1]);
               break;
           unzip(zin, e.getName());
        zin.close();
      public static void unzip(ZipInputStream zin, String s) throws IOException {
        System.out.println("unzipping " + s);
        FileOutputStream out = new FileOutputStream(s);
        byte [] b = new byte[512];
        int len = 0;
        while ( (len=zin.read(b))!= -1 ) {
          out.write(b,0,len);
        out.close();
    Courtesy of : http://www.rgagnon.com/javadetails/java-0067.html and http://www.rgagnon.com/howto.html

  • Can't properly unzip archive when use  ZipInputStream

    Hello.
    Have some problem with ZipInputStream.
    I have two simple tasks:
    1. Download zip file from web.
    2. Unzip file.
    Zipped archive contains four text files.
    So, all of the above is simply resolved with a help of ZipFile class, but when i use ZipInputStream, i got only one of four files unzipped in output, where i am did a mistake?
    Here is the code:
    URL url01=new URL(....);
    ZipInputStream zis01=new ZipInputStream(url01.openStream());
                ZipEntry zipEntry;
              while((zipEntry=zis01.getNextEntry())!=null){
                    if(!zipEntry.isDirectory()){
                        PrintStream ps01=new PrintStream(new FileOutputStream(zipEntry.getName()),true);
                        BufferedReader bffr01=new BufferedReader(new InputStreamReader(zis01));
                       String line;
                        while((line=bffr01.readLine())!=null){
                            ps01.println(line);
                        ps01.close();
                    zis01.closeEntry();
                zis01.close();Edited by: 814785 on Sep 4, 2011 6:03 PM

    EJP wrote:
    PrintStream also swallows exceptions.Of course you are right. I handle all necessary exceptions ...You're missing the point. PrintStream doesn't throw them in your code. None of the print() or println() methods throws any exception at all. You have to write extra code. You have to call checkError(). See the Javadoc.Thank you, EJP, I'm already know about this moment. The question is about ZipInputStream behavior, not about how to catch and handle exceptions. There is no exceptions in my code. I tried methods with buffering, without buffering - no success.
    As i wrote, the solution is in compression method. ZipFile works - that is enougth, ZipInputStream understrand only old zip archives, to be more exact: method getNextEntry() can't read all entries. You can do your own test, i can send you my archive if you want.
    One of other variant of code without any buffers (also doesn't work properly):
    ZipInputStream zis01=new ZipInputStream(new FileInputStream("unzipme.zip"));
                ZipEntry zipEntry;
                while((zipEntry=zis01.getNextEntry())!=null){
                    if(!zipEntry.isDirectory()){
                        FileOutputStream fos01=new FileOutputStream(zipEntry.getName());
                        int count;
                        while((count=zis01.read())!=-1){
                            fos01.write(count);
                        fos01.close();
                    zis01.closeEntry();
                zis01.close();Edited by: user124 on Sep 5, 2011 4:34 PM
    Edited by: user124 on Sep 5, 2011 4:48 PM

  • Zip.ZipInputStream cannot extract files with Chinese chars in name

    Dear friends,
    Peace b upon u!
    I am trying to read a zip file (~3000 files)containing one
    or more files with Chinese, Japanese or Korean names, the
    getNextEntry method throws an IllegalArgumentException as below after extracting just ~300 files as below:-
    java.lang.IllegalArgumentException
            at java.util.zip.ZipInputStream.getUTF8String(Unknown Source)
            at java.util.zip.ZipInputStream.readLOC(Unknown Source)
            at java.util.zip.ZipInputStream.getNextEntry(Unknown Source)
            at testZipFiles.getZipFiles(testZipFiles.java:65)
            at testZipFiles.main(testZipFiles.java:18) issue:java.util.zip.ZipInputStream cannot extract files with Chinese chars in name
    Category java:classes_util_jarzip
    Plz let me know 1 of the ways which I can solve this issue.
    1)if someone has JAVA DCOMPILER plz send the SOURCE Code
    for the ZipInputStream.class to me..I need to edit it using 1 of the solutions as provided below which I googled.
    2)If there is an alternate or upgraded java.util.zip.ZipInputStream or any org.apache.tools.zip.* package which can read such files..If yes where I can download the same on net.
    3)Any other easier solution, which can let me extract all files (by excluding Chinese files thru CATCH) without the extractor process to fail altogether.
    On net I found that the only solution with this is:-
    - edit the new ZipEntry, remove the static initializer that calls
    the native methods initIDs().
    this step seems a bit scary, but it's according to the
    workaround
    to bug #4244499 (the workaround of Olive64, THU JUN 05
    01:55 P.M. 2003),
    that handles a similar bug at the ZipOutputStream.
    Now you have a ZipInputStream that supports multi-bytes
    entry names.
    to extract the zip file, using the fixed code that is offered
    above,
    create a function that gets an "encoding" string, a "destPath"
    string
    and a "sourceFile" (zipped) and does :
    ZipInputStream zipinputstream = null;
    ZipEntry zipentry;
    zipinputstream = new ZipInputStream(new FileInputStream
    (sourceFile),encoding);
    zipentry = zipinputstream.getNextEntry();
    while (zipentry != null) { //for each entry to be extracted
        String entryName = zipentry.getName();
        int n;
        FileOutputStream fileoutputstream = new FileOutputStream
    ( destPath + entryName );
        while ((n = zipinputstream.read(buf, 0, 1024)) > -1)
            fileoutputstream.write(buf, 0, n);
        fileoutputstream.close();
        zipinputstream.closeEntry();
        zipentry = zipinputstream.getNextEntry();
    }//while
    zipinputstream.close();

    Hi friend,
    We'd better to ask one question in each thread. If you have another issue, you can consider to open up a new thread in this forum.
    Now for the first question, do you mean this picture? It throws access exception in archive2.
    If so , because your extractPath is a path, not a directory.You should add +"xxx.zip". For more information, please refer to
    ZipFile.Open
    Method (String, ZipArchiveMode).
    For the second question, you can use the following code to skip the error message.
    while (true)
    try
    //do something;
    catch (Exception ex)
    { continue; }
    Good day!
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • OALL8 is in an inconsitent state

    I am having a problem with a sql query, that i execute through JDBC. I get a SQLJ exception with the message "OALL8 is in an inconsitent state"
    It only happens when I execute this particular query. All the other queries i execute, return normally.
    Can anyone help me with this problem?
    Further info:
    On my Oracle 11G server i get the following message in my alert log:
    Mon Aug 17 12:48:38 2009
    Exception \[type: ACCESS_VIOLATION, UNABLE_TO_READ\] \[ADDR:0x2ED94D98\] \[PC:0x7B11692, kggfaDoKghAlloc()+122\]
    Errors in file c:\oracle11g\diag\rdbms\epjdb4\epjdb4\trace\epjdb4_ora_284.trc (incident=5768):
    ORA-07445: undtagelse fundet: core dump \[kggfaDoKghAlloc()+122\] \[ACCESS_VIOLATION\] \[ADDR:0x2ED94D98\] \[PC:0x7B11692\] \[UNABLE_TO_READ\]
    from the trace fil i find that the SQL i am executing looks like this:
      WITH services AS (
        SELECT y.pk, y.guid
          FROM actions y
         WHERE y.personlink = :1
           AND (y.endtime >= :2  OR y.endtime IS NULL)
           AND y.id LIKE 'CLINICAL.ACTION%'
           AND NOT (y.status = 4)
           AND (
                 ( y.decisiontime <= :3
                   AND NOT y.id = 'CLINICAL.ACTION.MEDICATION'
                 OR
                   y.id = 'CLINICAL.ACTION.FOLDER'
      SELECT y.pk pk FROM services y
      UNION
      SELECT folder.pk FROM Actions folder WHERE folder.guid IN (SELECT folderLnk.FROMLINK FROM links folderLnk
        START WITH
          folderLnk.TOLINK in (SELECT y.GUID FROM services y) AND
          folderLnk.ID = 'CLINICAL.ACTION.FOLDER.CONTENTS'
        CONNECT BY PRIOR folderLnk.FROMLINK = folderLnk.TOLINK and folderLnk.ID = 'CLINICAL.ACTION.FOLDER.CONTENTS')
      UNION
      SELECT aps.pk pk
        FROM services y, links l, actions aps
       WHERE l.fromlink = y.guid
         AND (   l.id = 'CLINICAL.ACTION.PLANNING'
              OR l.id = 'CLINICAL.ACTION.STATUS.HISTORY')
         AND l.tolink = aps.guidpfile setup:
    db_block_size=8192
    open_cursors=300
    db_domain=""
    db_name=EPJDB4
    control_files=("C:\Oracle11g\oradata\EPJDB4\control01.ctl", "C:\Oracle11g\oradata\EPJDB4\control02.ctl", "C:\Oracle11g\oradata\EPJDB4\control03.ctl")
    compatible=11.1.0.0.0
    diagnostic_dest=C:\Oracle11g
    memory_target=7387217920
    nls_language="DANISH"
    nls_territory="DENMARK"
    local_listener=LISTENER_EPJDB4
    processes=150
    audit_file_dest=C:\Oracle11g\admin\EPJDB4\adump
    audit_trail=db
    remote_login_passwordfile=EXCLUSIVE
    dispatchers="(PROTOCOL=TCP) (SERVICE=EPJDB4XDB)"
    undo_tablespace=UNDOTBS1
    Edited by: user11797103 on 2009-08-17 05:09

    Hello damorgan,
    The firs select statement only return one value, the primary key of y. The select which does in fact return two values is the one inside the "WITH x AS SELECT..." statement. The query actually works on another Oracle 11G DB server.
    I just found out that any change in the phrasing of the statement, even introducing an extra new line character, makes the problem go away.
    A collegue of mine suggests that the server has somehow cached the statement and done some kind of unhealthy optimization of its execution plan.
    The oracle error code give in the alert log apparently indicates an internal oracle error. I will try creating a service request on metalink, as soon as I can get access.
    Best regards
    Søren

  • Strange behavior of ZipInputStream

    I have a problem with ZipInputStream. Essentially, I receive and InputStream (that's why I cannot use ZipFile), and I need to unzip it and read all its entries. The problem is that the entries are xml files, so I need to build the dom, but when I call DocumentBuilder.parse, it reads all the input stream, and closes it. So, I've tried to read one entry at once, and parse it; but now it seems that ZipEntry.getSize() always returns a -1 length. Could someone explain me why? Also, do you know any good online resource about this? Because Ive done several searches but never found something useful. Thanks
              ZipInputStream iz = new ZipInputStream( is ); // "is" is an InputStream
              try
                   while( iz.available() == 1 )
                        ZipEntry entry = iz.getNextEntry();
                        if( entry != null )
                        if( entry.getSize() != -1 )
                        if( entry.getName().endsWith( "header.xml" ) )
                             long n = entry.getSize();
                             byte[] bytes = new byte[(int)n];
                             iz.read( bytes );
                             new ByteArrayInputStream( bytes );
                             XmlNode xml = new XmlNode( new ByteArrayInputStream( bytes ) ); // This calls DocumentBuilder.parse
                             project.setName( xml.path( "header/name" ).getValue( "Project" ) );
                             continue;
                        else
                        // do something
                   iz.close();
              catch( IOException ioe )
                   ioe.printStackTrace();
              }

    It should, but it does not; I've put the code in a stand-alone class. You can compile it and launch it by specifying a zip file on the command line. I always get: Size of TestFileN: -1
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipInputStream;
    public class ZipTest
         public static void main( String[] args )
              try
                   parse( new FileInputStream( new File( args[0] ) ) );
              catch( IndexOutOfBoundsException oe )
                   System.out.println( "No filename given" );
              catch( FileNotFoundException e )
                   System.out.println( "File not found: " + args[0] );
         public static void parse( InputStream is  )
              ZipInputStream iz = new ZipInputStream( is );
              try
                   while( iz.available() == 1 )
                        ZipEntry entry = iz.getNextEntry();
                        if( entry != null )
                             System.out.println( "Size of " + entry.getName() + ": " + entry.getSize() );
                   iz.close();
              catch( IOException ioe )
                   ioe.printStackTrace();
    }

  • Is there a way to reset ZipInputStream?

    Hi,
    My api receives as an input a ZipInputStream, and processes certain files in the stream. The algorithm that this api implements needs to scan the files back and forth multiple times. So I would either read all the files into the JVM and do the scannings in memoty, or somehow be able to "reset" the stream so that at most one file at a time needs to be in memory. I prefer the 2nd approach because the number of files in the stream is unknown, and the 1st approach might cause a momery issue. However, I googled ZipInputStream and got the impression the the ZipInputStream as it is cannot reset.
    Did I miss something or understand it wrong?
    Any inputs? thanks very much,

    gftech wrote:
    Hi,
    My api receives as an input a ZipInputStream, and processes certain files in the stream. The algorithm that this api implements needs to scan the files back and forth multiple times. So I would either read all the files into the JVM and do the scannings in memoty, or somehow be able to "reset" the stream so that at most one file at a time needs to be in memory. I prefer the 2nd approach because the number of files in the stream is unknown, and the 1st approach might cause a momery issue. However, I googled ZipInputStream and got the impression the the ZipInputStream as it is cannot reset.
    Did I miss something or understand it wrong?
    Any inputs? thanks very much,What is the source? A socket?

  • ZipInputStream.getNextEntry() closes stream?

    I have this functionality wherein i need to read from the same zipfile, but at different times. But once I've read it the first time, it won't let me do it again, it throws a -
    java.io.IOException: Stream closed.
    at jazz.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:143)
    I've tried assigning the ZipInputStream I have to another (like a temp zipfile) and then trying to re-read from the original zipfile, but it still throws me the error.
    Code -
    ZipInputStream zis = mResourceFiles; (this is the original zipfile)
    if (null != zis) {
    String filename = "";
    while ((filename = zis.getNextEntry().getName()) !=null) {
    // add entry to xml file
    sLog.debug("in zis==" + filename);
    ... do something .....
    and then there's another method that uses the same zipfile (mResourceFiles - which is a member variable) and tries to read from it.
    I'm not closing the stream anywhere. I understand that I cannot re-read from a zipfile once I've read from it. What then could be the soln to this?
    Thanks in advance!
    HS

    Hmm .. I've tried creating a new ZipInputStream too - here's what I'm really doing ..
    I have a method that reads all files in the ZipInputStream (member variable in class) by doing this -
    ZipInputStream zis = new ZipInputStream(mResources);
    if (null != zis) {
         ZipEntry entry;
         int offset = 0;
         while ((entry = zis.getNextEntry()) !=null) {
         // add entry to zip file
         zos.putNextEntry(entry); // ZipOutputStream
         // write file
         byte[] buf = new byte[1024];
         int len;
         while ((len = zis.read(buf)) > 0){
         zos.write(buf, 0, len);
         zos.closeEntry();
    Now in another method, I need to get all entries from the same zipfile - reassigning to a new ZipInputStream still throws me the 'Stream closed' error.
    Also, creating a new instance of ZipInputStream (like above) instead of just assigning it to another ZipInputStream throws me the following error -
    Caused by: jazz.util.zip.ZipException: EOF in header
    at jazz.util.zip.ZipInputStream.readLeByte(ZipInputStream.java:115)
    at jazz.util.zip.ZipInputStream.readLeShort(ZipInputStream.java:125)
    at jazz.util.zip.ZipInputStream.readLeInt(ZipInputStream.java:133)
    at jazz.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:147)
    I use ZipInputStream, as opposed to ZipFile as I get passed the zipfile as a ZipInputStream from another class.
    Need help!! :)

  • ZipInputStream & ZipEntry taking time to unzip big file

    Hi,
    We have big zip file around 2GB which needs to downloaded and unzipped. We are using ZipInputStream & ZipEntry for unzipping the files.
    This is taking around 45 min to unzip the file. Do we have better alternative for doing the same?
    Thanks in advance
    Regards,
    Ravi

    Below is the code we are using:
    public void getZipFiles(String sSourcePath, String sDestPath)
            try
                sDestPath = sDestPath + Util.getFileSeparator();
                byte[] buf = new byte[1024];
                ZipInputStream zipinputstream = null;
                ZipEntry zipentry;
                BufferedOutputStream  outBuffer =null;
                BufferedInputStream inBuffer = null;
                zipinputstream = new ZipInputStream(
                    new FileInputStream(sSourcePath));
                String sFile =sSourcePath.substring(0,  sSourcePath.indexOf("."));
            File f = new File(sFile);
            if(f.mkdir())
                System.out.println( f + " Directory Created");
            else
            System.out.println(f + " Directory is not created");
                zipentry = zipinputstream.getNextEntry();
                while (zipentry != null)
                    //for each entry to be extracted
                    String entryName = zipentry.getName();
                    int n;
                    if(zipentry.isDirectory())
                        File f1 = new File(sDestPath+zipentry.getName());
                         if(f1.mkdir())
                                System.out.println(f + " Directory Created");
                            else
                            System.out.println(f + " Directory is not created");
                    else
                    FileOutputStream fileoutputstream;
                    File newFile = new File(entryName);
                    String directory = newFile.getParent();
                    if(directory == null)
                        if(newFile.isDirectory())
                            break;
                    fileoutputstream = new FileOutputStream(sDestPath+entryName);
                    outBuffer = new BufferedOutputStream(fileoutputstream);
                    inBuffer = new BufferedInputStream(zipinputstream);
                   /* while ((n = zipinputstream.read(buf, 0, 1024)) > -1)
                        fileoutputstream.write(buf, 0, n);*/
                    while(true){
                       int bytedata = inBuffer.read();
                      if(bytedata == -1)       break;
                      outBuffer.write(bytedata);
                    outBuffer.flush();
                    fileoutputstream.close();
                    fileoutputstream.flush();
                   // zipinputstream.closeEntry();
                    zipentry = zipinputstream.getNextEntry();
                }//while
                zipinputstream.close();
                outBuffer.close();
                inBuffer.close();
            catch (Exception e)
                e.printStackTrace();
        }Edited by: EJP on 5/02/2013 22:07: code tags

  • ZipEntry, ZipInputStream, ZipFile (problems)

    This is driving me nuts.
    Basically, this code should read in the entries of a ZipFile and print the entry name alongside the decompressed data of the entry. Help finding the mistake or fundamental flaw would be appreciated.
    Just in case it matters. The zip file I've been testing this on has two entries, both text files with less than 1k of data each (stuff like "TESTING!" etc.). The zip file was made with Windows XP's built in compression utility (dragged and dropped), and was then renamed to FAQ.info .
    Currently, the code prints out the name of the entries (and the hyphen) but not the data.
    try{
    ZipFile zf=new ZipFile("FAQ.info");
    Enumeration e=zf.entries();
    while(e.hasMoreElements()){
    ZipEntry ze=(ZipEntry)e.nextElement();
    ZipInputStream zis=new ZipInputStream(zf.getInputStream(ze));
    byte[] b=new byte[(int)ze.getSize()];
    int size=(int)ze.getSize();
    int total=0;
    String entry="";
    while(size-total>0){
    //System.out.print(size+" - "+total);
    int x=zis.read(b,total,size-total);
    //System.out.println(" - "+x);
    if(x==-1){
    entry+=""+new String(b,0,size-total);
    break;
    }else{
    entry+=""+new String(b,0,x);
    }//if
    total+=x;
    }//while
    System.out.println(ze.getName()+" - "+entry);
    }//while
    }catch(Exception f){f.printStackTrace();}-Rejun

    Use something like this to extract data from a zip entry
    try {
        zis = new ZipInputStream(new FileInputStream(zipFile));
        while ( (entry = zis.getNextEntry()) != null) {    byte[] buf = new byte[1024];               
            int readIn = 0;
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            while ( (readIn = zis.read(buf)) > 0) {
                bos.write(buf, 0, readIn);
            bos.close();
            // process ur data
            zis.closeEntry();
    }

  • Inconsitency in   BSIS &  BSAS Tables

    Due to the messup done by the consultants engaged by our organisation for SAP implementation with respect to SEM & BCS consolidation over and above the other goofups they made, we had to update certain fields ( Trading Partner & Recon Account - meant for related parties) directly in the tables.
    After such updation we encountered line itme reports not matching the Totals. We reset back the reconcilation accounts to the Orginal value. All tables except the BSIS & BSAS are ok, due to certain duplicate reocrds in BSIS and BSAS tables vis a vis BSID, BSAD, BSIK & BSAK, can anyone advice and /or guide us as to the repurcussions if we delete these duplicate rows in BSIS and BSAS with respect to report generation, future transactions, closing etc.
    Message was edited by:
            Brad Master

    It is baffling how SEM and BCS consultants ended up messing up your R/3 tables. That is one of the reason why there is always a separate ownership of the two process areas. Best practice is to have separate owners for FI and BCS areas. Never the twain shall meet!
    Regardless of who is to blame for the messup, it is NEVER a good idea for you to update the SAP tables directly. Period. No exceptions.
    The fact that someone (inhouse or same consultants?) actually suggested you do that and you did that is symptomatic of deeper problems in your organization.
    My two cents: don't paper over the already exacerbated problem. Get rid of cheap consultants and get some knowledgeable help.

  • SQL query returning data inconsitantly

    I am running Oracle 8i and have create a stored procedure that has a cursor in it. The select statement for the cursor returns 15 records that I loop through and insert into another table. At the beginning of the loop, just before the insert statement, I have also created DBMS output that will return the time stamp. This more or less tells me how long each loop takes to complete. The loop processes 14 of the 15 records in less than a minute. The last loop takes over two hours to complete. I have also tried running this stored proc in another environment. In that environment the cursor should process 3555 records. It processes 2650 in five minutes or less. It then takes about 115 minutes to process the last 905. Does anyone have any ideas as to why this may be occurring? Could there be a bottleneck somewhere? What DB/table settings can I look at? Thanks in advance for you ideas.

    Please check the query plan in this environment and that environment also(It processes 2650 in five minutes or less)

  • FMIFIIT and FMIOI inconsitent with FMAVCT

    Hi:
    I am facing an issue while reconciling budget data for my client. FMAVCT summary amount is when consolidated for local currency is not tallying with the sum of FMIFIIT and FMIOI. I came to know to that funded program was not part of control object which could might be causing the difference between these two. I added it to derivation for control objects by using assignment and then I did reinitialization of  AVC ledger but still result is same by unchecking reset index table but still the same inconsistencies exist. Really clueless what is causing the difference between these. Can someone please shed light on it.
    Thanks

    Hi Atif,
    I do not know what report you ran and made you say there were inconsistencies. Maybe you can provide some more information, screenshots etc.
    Regards,
    Ming

Maybe you are looking for

  • Exceptions are not working. Is Java installed correctly?

    This is the situation: import java.lang.Exception; public class ExceptionTest     class ExtendException extends Exception         ExtendException(String x)             super(x + " is bad.");     public static void main(String[] args)         throw Ex

  • Oracle9i Database Release 2 Enterprise for HP 9000 Series HP-UX

    Is the "Oracle9i Database Release 2 Enterprise/Standard Edition for HP 9000 Series HP-UX" really running only on HP-UX 64 bit. No chance on 32 bit? Werner

  • Live monitoring of sip usage

    Regular PBX systems often times have a live monitoring tool you can use to see who is currently on the phone and who isn't and it operates in real time. Does Lync have a feature like this? We are rolling out a flow blown Lync platform and would like

  • Purchased music on new computer/will not load on ipod

    This problem has gone on for months now and I'm at my wits end. I have a 2nd PC which I have authorized. Windows 2000 Business Ed. When I connect my IPod, I cannot get the music I have recently purchased from itunes 7.0 to upload on my 60/Video IPod.

  • Warning before aggregation is osbsolete

    Hi guru's I'm migrating our BW system and in some queries we have the message Warning calculation before aggregation is obsolete. We still use BW 3.x analyzer. when i execute queries the message is only a warning and i can see result in my reports. i