Six Stars

How to Convert image to base64 format ?

How to convert the images into the base64 encode and decode 

 

We use the tJavaRow for encode base64 --->>

 

//Start

 

File file = new File("/home/user/logo.png");
byte[] bytes = loadFile(file);
String s = new sun.misc.BASE64Encoder().encode(bytes); 

System.out.println(s);

 

//end

 

error Message:

Detail Message: File cannot be resolved to a type

 

Can you guide me further process

2 REPLIES
Twelve Stars

Re: How to Convert image to base64 format ?

Go to your tJavaRow's Advanced Settings and add this line of code....

 

import java.io.File;
Rilhia Solutions
Six Stars

Re: How to Convert image to base64 format ?

Program : tJavaRow

code:

 

File file = new File("/home/user/logo.png");
FileInputStream imageInFile = new FileInputStream(file);
byte imageData[] = new byte[(int)file.length()];
imageInFile.read(imageData);
//String imageDataString = encodeImage(imageData);
String imageStr = new sun.misc.BASE64Encoder().encode(imageData);
System.out.println("OKAy:"+imageStr);
imageInFile.close();

No error shown but we cannot get return any string value "System.out.println("OKAy:"+imageStr);"