Accessing files within JAR archive
From: Bert Sierra (bert_sierra_at_mac.com)
Date: 10/30/03
- Next message: David Gavini: "Re: UnsupportedOperationException is thrown inconsistently"
- Previous message: Thomas Schodt: "Re: solving a mathematical brain teaser"
- Next in thread: Anthony Borla: "Re: Accessing files within JAR archive"
- Reply: Anthony Borla: "Re: Accessing files within JAR archive"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Oct 2003 02:30:09 -0700
Howdy --
I'm fairly new to Java, so I'm easily stumped. The question is: How do
I access a file within a JAR archive from a Java program?
I have a simple test program, shown below, which illustrates the problem:
import java.io.*;
import java.util.*;
public class FileTest {
public static void main (String args[]) {
File file = new File("test.gif");
System.out.println("exists = " + file.exists());
System.out.println("length = " + file.length());
}
}
If I store the test.gif file outside the JAR archive, in the same
directory as the JAR archive, everything runs fine -- the file exists
and I get the proper length. If I store the test.gif file in the JAR
archive, it can't be found and length()==0. None of the Java texts I
have on hand seem to address this issue.
TIA...
-- Bert Sierra
bert_sierra@mac.com
- Next message: David Gavini: "Re: UnsupportedOperationException is thrown inconsistently"
- Previous message: Thomas Schodt: "Re: solving a mathematical brain teaser"
- Next in thread: Anthony Borla: "Re: Accessing files within JAR archive"
- Reply: Anthony Borla: "Re: Accessing files within JAR archive"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|