- 일반적인 java 소스로 한글 문서를 base64로 변환 했을 경우와 한글기안기에서 base64로 변환 되는 base64 string값이 상이
- 일반 적인 java 소스
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
import com.hwp.util.*;
public class HwpBase64Util {
/**
* HWP 파일 → Base64 문자열 변환
*/
public static String hwpToBase64(String filePath) throws IOException {
byte[] fileBytes = Files.readAllBytes(Paths.get(filePath));
//return Base64.getEncoder().encodeToString(fileBytes);
return Base64.getEncoder().encodeToString(fileBytes);
}
/**
* 실행용 main 메서드 (Base64 전체 출력)
*/
public static void main(String[] args) {
// HWP 파일 경로
String inputFile = "C:\\Users\\RYU\\Downloads\\WMF.hwp";
try {
String base64 = hwpToBase64(inputFile);
System.out.println("=== Base64 전체 출력 시작 ===");
System.out.println(base64);
System.out.println("=== Base64 전체 출력 끝 ===");
System.out.println("Base64 길이 : " + base64.length());
} catch (IOException e) {
e.printStackTrace();
}
}
}
-
원본 한글 파일 첨부
WMF.hwp (19.5 KB)