2
Java에서 다운로드하려고하는 이미지 목록이 있습니다. 작동 방식 :유효한 파일 경로가 java.io.FileNotFoundException을 던졌습니다
for (String i : link_array) {
File image = new File(outputFolderImages, image_id+".gif");
if (!image.exists()) {
System.out.println("Downloading: "+i+" to file "+image);
FileUtils.copyURLToFile(new URL(i), image, 10000, 10000);
}
}
그러나 내가 쓰고있는 프로그램의 다른 부분은 이미 이미지 링크에있는 경로를 사용해야합니다. 따라서 이것이 the link 인 경우 이미지를 05785.gif
으로 저장하고 싶습니다. 그래서 나는이 시도 :
for (String i : link_array) {
String x = i.replace("http://www.mspaintadventures.com/storyfiles/hs2/","");
File image = new File(outputFolderImages, x);
if (!image.exists()) {
System.out.println("Downloading: "+i+" to file "+image);
FileUtils.copyURLToFile(new URL(i), image, 10000, 10000);
}
}
을하지만이 오류가 발생합니다 :
이 유효한 파일 경로 비록Exception in thread "main" java.io.FileNotFoundException: C:\Users\Ian\Homestuck\images\05785.gif
(The filename, directory name, or volume label syntax is incorrect)
; 위의 첫 번째 코드 비트를 사용하여 수백 개의 다른 이미지를 저장했습니다. 이 문제를 어떻게 해결할 수 있습니까?
은 상위 디렉토리입니까? –
예, 저는 수천 개의 다른 이미지를 저장하기 위해 첫 번째 코드 블록을 사용했습니다. –
두 블록이 동일한 방법을 사용하고 있습니까? 'outputFolderImages'를 변경하는 코드를 가지고 있을까요? –