View Single Post
  #1 (permalink)  
Old 12-18-2007, 03:40 PM
Mr tuition Mr tuition is offline
Member
 
Join Date: Dec 2007
Posts: 10
Mr tuition is on a distinguished road
reading from a zip file, error
Im trying to read a file from a zip file using the following method:

PHP Code:
public void readZipFiles(String filename)
    {
        try
        {
            
byte[] buf = new byte[1024];
            
ZipInputStream zipinputstream null;
            
ZipEntry zipentry;
            
zipinputstream = new ZipInputStream(
                 new 
FileInputStream(filename));

            
zipentry zipinputstream.getNextEntry();
            while (
zipentry != null
            { 
                
//for each entry to be extracted
                
String entryName zipentry.getName();
                
System.out.println("File ::"+entryName);
                
RandomAccessFile  rf;
                
File newFile = new File(entryName);
                
String directory newFile.getParent();
                if(
directory == null)
                {
                    if(
newFile.isDirectory())
                        break;
                }
                
System.out.println("d" );
                
rf = new RandomAccessFile(entryName,"r");               
                
System.out.println("e" );
                
String line;

                if ((
line =rf.readLine()) !=null)
                {
                    
System.out.println(line);
                }

                
rf.close(); 
                
zipinputstream.closeEntry();
                
zipentry zipinputstream.getNextEntry();

            }
//while

            
zipinputstream.close();
        }
        catch (
Exception e)
        {
            
e.printStackTrace();
        }
    } 
but just after System.out.println("d" ); I get an error?

File:: jav_4250.pdf
a
b
c
d
java.io.FileNotFoundException: jav_4250.pdf

but why is it not found if it just got it from the zip?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote
Sponsored Links