How do I read a resource file from a Java jar file?

后端 未结 9 1598
遥遥无期
遥遥无期 2020-11-22 09:22

I\'m trying to access an XML file within a jar file, from a separate jar that\'s running as a desktop application. I can get the URL to the file I need, but when I pass tha

9条回答
  •  难免孤独
    2020-11-22 10:12

    If you use resources extensively, you might consider using Commons VFS.

    Also supports: * Local Files * FTP, SFTP * HTTP and HTTPS * Temporary Files "normal FS backed) * Zip, Jar and Tar (uncompressed, tgz or tbz2) * gzip and bzip2 * resources * ram - "ramdrive" * mime

    There's also JBoss VFS - but it's not much documented.

提交回复
热议问题