🏫 Program Language/☕ JAVA JAVA Converting File to MultiPartFile 728x90 Good moring or afternoon sir. Today, I'm sharing you how to convert [File to MultiPartFile] in JAVA. Trust Me! This is the code I'm actually using in my system :) 1. You can use CommonsMultipartFile An example of a filePath is shown below. ex) C:/Users/han/test.xlsx File yourFile = new File(filePath); DiskFileItem fileItem = new DiskFileItem("file", Files.probeContentType(yourFile.toPath()), false, yourFile.getName(), (int) yourFile.length() , yourFile.getParentFile()); InputStream input = new FileInputStream(yourFile); OutputStream os = fileItem.getOutputStream(); IOUtils.copy(input, os); MultipartFile multipartFile = new CommonsMultipartFile(fileItem); I hope this is the result you want. If it's not working or if you have any questions, please leave a comment. Have a nice day! 반응형 공유하기 URL 복사카카오톡 공유페이스북 공유엑스 공유 게시글 관리 구독하기팀드모네 IT Blog 저작자표시 비영리 변경금지 (새창열림) '🏫 Program Language > ☕ JAVA' 카테고리의 다른 글 Where can I download openjdk 1.8? (0) 2024.06.11 jad로 class 컴파일 하는 방법 (0) 2019.02.28 java 배열 길이를 구하는 함수 (0) 2018.10.15 java String을 int로 바꾸는 방법 (0) 2018.10.15 java int를 String으로 바꾸는 방법 (0) 2018.10.15 Contents 당신이 좋아할만한 콘텐츠 Where can I download openjdk 1.8? 2024.06.11 jad로 class 컴파일 하는 방법 2019.02.28 java 배열 길이를 구하는 함수 2018.10.15 java String을 int로 바꾸는 방법 2018.10.15 댓글 0 + 이전 댓글 더보기