列出Jar包中的文件

String fileName = "src.zip";

		// 取得jar包对象
		JarFile file = new JarFile(fileName);

		Enumeration<JarEntry> entries = file.entries();
		while (entries.hasMoreElements()) {
			JarEntry entry = entries.nextElement();

			String entryName = entry.getName();
			System.out.println("entryName:" + entryName + "  "
					+ entry.isDirectory());

			byte[] tempbytes = new byte[100];
			InputStream in = file.getInputStream(entry);
			int byteread = 0;
			while ((byteread = in.read(tempbytes)) != -1) {
				System.out.write(tempbytes, 0, byteread);
			}

		}
 

你可能感兴趣的:(jar包)