For Programmers: Free Programming Magazines  


Home > Archive > Java Help > March 2004 > FileInputStream with jar









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author FileInputStream with jar
ambika

2004-03-28, 12:01 am

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...
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com