reading from a zip file, error
Im trying to read a file from a zip file using the following method:
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?