Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-18-2007, 03:40 PM
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-16-2008, 01:39 AM
undertow's Avatar
Member
 
Join Date: Jan 2008
Location: Colorado USA
Posts: 12
undertow is on a distinguished road
Send a message via AIM to undertow Send a message via Skype™ to undertow
The file is still in the ZIP file. once you find the zipentry you want, you have to go through the process of extracting that file so you can use it. Or if you dont want to extract it you would simply get the inputstream of the particular entry from the Zipfile Object.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading a file mew New To Java 2 12-30-2007 01:23 PM
Reading a file for use peachyco New To Java 2 11-27-2007 04:49 AM
Reading Data from a file ramachandran New To Java 2 10-24-2007 08:22 AM
Help with File reading and writing baltimore New To Java 1 07-31-2007 07:47 PM
Reading from a file leebee New To Java 1 07-23-2007 01:02 PM


All times are GMT +3. The time now is 12:38 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org