List of usage examples for android.util Base64 encodeToString
public static String encodeToString(byte[] input, int offset, int len, int flags)
From source file:com.sogrey.sinaweibo.utils.FileUtil.java
/** * ?Base64/*from www. j a va2 s . c om*/ * * @author Sogrey * @date 2015723 * @param path * @return */ public static String getBase64FromPath(String path) { String base64 = ""; try { File file = new File(path); byte[] buffer = new byte[(int) file.length() + 100]; @SuppressWarnings("resource") int length = new FileInputStream(file).read(buffer); base64 = Base64.encodeToString(buffer, 0, length, Base64.DEFAULT); } catch (IOException e) { e.printStackTrace(); } return base64; }