java2 FileNotFoundException에러, 크롤링 작업 중 만난 오류,절대 눈을 믿지마라 크롤링을 통해, fileName을 얻고 FileOutputStrema(fileName)을 통해 이미지 파일을 생성하고, 이를 통해 엑셀파일을 만드는 작업을 하고 있었다. System.out을 통해서 값을 찍어보며 디버깅 하고 있었는데 문제가 전혀 해결되지 않았다.. 잘안된다 싶으면 눈을 믿으면 안된다.. 디버깅 도구를 잘 쓰자!! 디버깅 결과, 크롤링 한 fileName값에 \n 값이 붙으면서 넘어오고 있었다. 이러니 당연히 파일을 못생성하지..! String fileName = imgURL.substring(imgURL.lastIndexOf(".",imgURL.lastIndexOf('.')-1)+1); fileName = fileName.replaceAll("(\r\n|\r|\n|\n\r)", "");.. 2023. 2. 14. JAVA String.lastIndexOf()로 2번째 lastIndex를 얻고 싶을 때?? 참고 : https://www.scaler.com/topics/lastindexof-in-java/ 정답은 영어로 구글링 하는 것에 있었다.. int lastIndexOf(String str, int fromIndex) lastIndexOf() 메서드는 위의 형태로 사용하고 결과로 index값을 반환한다. 2번째 파라미터는 선언하면 그 인덱스에서 시작하여 마지막 index를 찾는 것으로 알려져 있다. public class LastIndex_test { public static void main(String[] args) { /*2번째 lastIndex얻기*/ String imgURL = "https://shopping-phinf.pstatic.net/main_3246668/32466681076.2023.. 2023. 2. 14. 이전 1 다음