Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is there any way to convert Jar Entry to a File Object

 
Bhagya Tangutur
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anyway i can convert File in Jar to File Object.
I am using some third party classes which needs File as an argument.so is there any work around to get Jar entry(some x File) to Convert to File Object.and i don't want to to create new files in hard disk to perform this work.
Thanks for your time
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumar- we ask that all our users follow our display name policy. Please
change]http://www.coderanch.com/forums/user/edit]change your display name[/url] to include both a first and last name. Thanks.
As for your question - it's easy to create a File object simply by using new File(name). However the third-party class you're using which expects a File object will probably also expect that there is a physical file on your hard drive which corresponds to this File object. (It will probably try to open a FileInputStream using the File object to read it.) Thus, you'll need to copy from the jar file into a new, separate file. Unless you can find another method in the 3rd-party API which uses, say, an InputStream rather than a File.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic