FileInputStream with jar

From: ambika (indambika_at_yahoo.com)
Date: 03/27/04


Date: 27 Mar 2004 11:40:02 -0800

Hello everyone,
                           Am having a small problem in reading from a
jar file.The size of the jar file is 611 bytes.When I try to read the
jar file using FileInputStream alone i get some value for j but when
I use it along with JarInputStream and check the value of j it is
-1.The FileInputStream is working very differently here.Can anyone
tell me why?

FileInputStream works just fine in the code below;

import java.util.jar.*;
import java.io.*;
class jartry
        {
        public static void main(String args[])throws Exception
                {
                FileInputStream fis=new FileInputStream("result.jar");
                int j;
                j=fis.read();
                System.out.println("value of fis:"+j);
                }
        }

Can anyone tell me how does the code below give an answer of -1 for
j???

import java.util.jar.*;
import java.io.*;
class jartry
        {
        public static void main(String args[])throws Exception
                {
                FileInputStream fis=new FileInputStream("result.jar");
                JarInputStream jis=new JarInputStream(fis);
                int j,i;
                j=fis.read();
                i=jis.read();
                System.out.println("value of fis:"+j);
                System.out.println("value of jis:"+i);
                }
        }
                

Thank You
ambika...



Relevant Pages

  • problem with FIleInputStream
    ... jar file.The size of the jar file is 611 bytes.When I try to read the ... -1.The FileInputStream is working very differently here.Can anyone ...
    (comp.lang.java.developer)
  • FileInputStream with jar
    ... jar file.The size of the jar file is 611 bytes.When I try to read the ... -1.The FileInputStream is working very differently here.Can anyone ...
    (comp.lang.java.programmer)