• Post Reply Bookmark Topic Watch Topic
  • New Topic

Attach file from JAR  RSS feed

 
Prashant Saraf
Ranch Hand
Posts: 57
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i am creating a application in which i m putting files in com.cmp.app.resource package. all files are doc or excel. I want to access that files using File class. how to use that
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are asking how to read xls/word files in java, This link will help you.
[ March 11, 2008: Message edited by: Nitesh Kant ]
 
Prashant Saraf
Ranch Hand
Posts: 57
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no.. problem is that i want to use a File object to access files from my jar. class and doc files are on same jar.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Prashant Saraf:
no.. problem is that i want to use a File object to access files from my jar. class and doc files are on same jar.


You can not use java.io.File to access those files. You have to use ZippedInputStream if you want to read a zip/jar/file and its entries.
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the JAR is on the classpath, you can get the data with the getResource()/getResourceAsStream() methods of java.lang.Class.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!