Here the report contain the path(pathname in sdcard in string format)
File dir = Environment.getExternalStorageDirectory(); File yourFile = new File(dir, report); String encodeFileToBase64Binary = encodeFileToBase64Binary(yourFile); private static String encodeFileToBase64Binary(File fileName) throws IOException { byte[] bytes = loadFile(fileName); byte[] encoded = Base64.encodeBase64(bytes); String encodedString = new String(encoded); return encodedString; }
in the byte[] encoded line getting this error. The method encodeBase64(byte[]) is undefined for the type Base64
Convert Files to Base64Just select your file or drag & drop it below, press the Convert to Base64 button, and you'll get a base64 string. Press a button – get base64. No ads, nonsense, or garbage. The input file can also be an mp3 or mp4.
How to convert string to Base64 online. Type or paste your text in the “Text” field. Press the “Encode Text to Base64” button. Copy or download the result from the “Base64” field.
To decode a file with contents that are base64 encoded, you simply provide the path of the file with the --decode flag. As with encoding files, the output will be a very long string of the original file. You may want to output stdout directly to a file.
String value = Base64.encodeToString(bytes, Base64.DEFAULT);
But you can directly convert it in to String .Hope this will work for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With