访问JAR文件夹中的文件 [英] Accessing files inside JAR folder
问题描述
你好朋友...
我已经开发了一个包含示例音频测试代码的JAR文件. JAR文件包含一个名为wavfile的文件夹,该文件夹保存项目的wavefile.我曾经通过在其中添加以下代码来获取JAR的当前目录:
I have developed a JAR file that contains the sample audiotesting code. The JAR file contains a folder called wavfile which holds the wavefiles of the project. I used to get the current dir of the JAR by adding the follwing code into it:
System.getProperties("User.dir"+"\\WavFile");
但是当我尝试在另一个Windows系统中运行此文件时,该文件无法正常工作.
But when I try to run this file in another Windows system it is not working.
代码搜索jar加载到的wavefile
The code searches for the wavefile where the jar has been loaded
例如:如果我在C:\\中加载JAR文件,则代码在C:\\中而不是在JAR文件中搜索wavefile文件夹,并抛出错误
For example: If I load my JAR file in C:\\ then the code searches for the wavefile folder in C:\\ and not inside the JAR file and throws me the error
File not found:C:\\WavFile\\English\\mysound.wav
对我有什么想法.....
Any ideas for me .....
推荐答案
您需要先提取文件. 这个站点应该可以帮助您从存档中取出文件.
You need to extract the file first. This site should help you with getting the file out of the archive.
这篇关于访问JAR文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!