-1

Say I have a jar call it foo.jar which contains a folder structure> ---com |---company |---jar |---metadata |---service |---config |---foo.xml

I then try to read the file from my code with

  FileOutputStream file = new FileOutputStream("/path/to/jar/foo.jar!/com/company/jar/metadata/service/config/foo.xml") 

This fails with java.io.FileNotFoundException foo.xml(Permission denied)

The jar in question has: -rw-r--r-- (644 if you prefer numeric)

What is causing this permissions problem? How can I fix it so as to avoid this happening in the future. And how do I configure mavan/intelliJ to install maven dependencies in such a way that this problem does not occur.

Abraham P
  • 15,029
  • 13
  • 58
  • 126
  • A .jar entry is not a separate file, it’s a sequence of bytes in an archive. You cannot use FileInputStream to read a .jar entry. – VGR Jan 26 '17 at 16:27

1 Answers1

1

If you want to read the JAR, I think you should use FileInputStream (for reading) instead of FileOutputStream (for writing).

FileInputStream file = new FileInputStream("/path/to/jar/foo.jar!/com/company/jar/metadata/service/config/foo.xml")
Mickael
  • 4,458
  • 2
  • 28
  • 40