Answers for "how to convert base64 to image in java"

0

java:image to base64 string example

       public static void main(String[] args) throws Exception{
 
           File f =  new File("/opt/myImage.jpg");
             String encodstring = encodeFileToBase64Binary(f);
             System.out.println(encodstring);
       }
 
       private static String encodeFileToBase64Binary(File file) throws Exception{
            FileInputStream fileInputStreamReader = new FileInputStream(file);
            byte[] bytes = new byte[(int)file.length()];
            fileInputStreamReader.read(bytes);
            return new String(Base64.encodeBase64(bytes), "UTF-8");
        }
Posted by: Guest on June-10-2021

Code answers related to "how to convert base64 to image in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language