Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 read file out of jar
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
matt271




PostPosted: Wed Jun 17, 2009 5:46 pm   Post subject: read file out of jar

in java how do u read a file out of its own jar?

say u made some program in netbeans and had netbeans package it into a jar for u, but u also have an image say "image.jpg"

how can i open it like File("image.jpg"); is its in the JAR file itself, not in the same dir as the jar file??

ty
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Wed Jun 17, 2009 7:19 pm   Post subject: RE:read file out of jar

Code:

import java.io.*;
import java.util.jar.*;
 .
 .
 .
Jar jar = new Jar("<path to jar file>");
ZipEntry imgEntry = jar.getEntry("image.jpg");

InputStream in = jar.getInputStream(imgEntry);
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: