ERROR RESOLVING

오류 Unhandled exception type IOException

Adev 2023. 1. 5. 23:44

상황

파일 업로드 구현 중 file.getInputStream();에 빨간줄이 떴다.

 

 

 

해결방법 2가지

방법1. 이클립스의 안내에 따라 try catch블록으로 감싸준다.

		try {
			InputStream is = file.getInputStream();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

 

방법2. 메소드에 throws IOException를 붙여 예외처리를 해준다.

public String Upload(@RequestParam("file") MultipartFile file) throws IOException{