OK, I have some pdf need convert to base64 by base64encoder.
finally, I use decoder to convert back to pdf format but my content is lost.
my code :
byte[] input_file = Files.readAllBytes(Paths.get("C:\\user\\Desktop\\dir1\\dir2\\test3.pdf"));
byte[] encodedBytes = Base64.getEncoder().encode(input_file);
String pdfInBase64 = new String(encodedBytes);
String originalString = new String(Base64.getDecoder().decode(encodedBytes));
System.out.println("originalString : " + originalString);
FileOutputStream fos = new FileOutputStream("C:\\user\\Desktop\\dir1\\dir2\\newtest3.pdf");
fos.write(originalString.getBytes());
fos.flush();
fos.close();
result :
Encode : https://pastebin.com/fnMACZzH
Thank You