java 代码
- public class TestReadJar {
- /**
- * @param args
- */
- public static void main(String[] args) throws IOException {
- String jarName="C://VODOSSClient.jar";
- String fileName="client.properties";
- JarFile jarFile = new JarFile(jarName);//读入jar文件
- JarEntry entry = jarFile.getJarEntry(fileName);
- InputStream input = jarFile.getInputStream(entry);//读入需要的文件
- readFile(input);
- jarFile.close();
- }
- private static void readFile(InputStream input)
- throws IOException {
- InputStreamReader isr =
- new InputStreamReader(input);
- BufferedReader reader = new BufferedReader(isr);
- String line;
- while ((line = reader.readLine()) != null) {
- System.out.println(line);
- }
- reader.close();
- }
- }