0
저장소의 jar 파일에 액세스하여 특정 파일을 검색하고 해당 파일을 검색하여 하드 디스크에 저장하고 싶습니다. 나는 항아리 전체를 다운로드하고 그것을 검색하고 싶지 않습니다.Java에서 전체 Jar를 다운로드하지 않고 저장소에있는 Jar 파일 가져 오기
그럼 Jar의 주소가 있다고 가정 해 보겠습니다. 누군가가 나머지 문제에 대한 코드를 제공 할 수 있습니까?
public void searchInsideJar(final String jarUrl, final String artifactId,
final String artifactVersion) {
InputStream is = null;
OutputStream outStream = null;
JarInputStream jis = null;
int i = 1;
try {
String strDirectory = "C:/Users/ilijab/" + artifactId +artifactVersion;
// Create one directory
boolean success = (new File(strDirectory)).mkdir();
if (success) {
System.out.println("Directory: " + strDirectory + " created");
}
is = new URL(jarUrl).openStream();
jis = new JarInputStream(is);
while (true) {
JarEntry ent = jis.getNextJarEntry();
if (ent == null) {
break;
}
if (ent.isDirectory()) {
continue;
}
if (ent.getName().contains("someFile")) {
outStream = new BufferedOutputStream(new FileOutputStream(
strDirectory + "\\" + "someFile" + i));
while(ent.)
System.out.println("**************************************************************");
System.out.println(i);
i++;
}
}
} catch (Exception ex) {
}
}
그래서 상위 코드에서 발견 된 파일 (마지막 if)을 어떻게 디렉토리에 저장할 수 있습니까?
"저장소"란 무엇을 의미합니까? Maven 저장소? –