文件转base64编码

	public String readPgm(String pgm_url) {
		
	File f = new File(pgm_url);
        if (!f.exists()) {
            return null;
        }
        FileInputStream fs;
        byte bytes[] = null;
        try {
            fs = new FileInputStream(f);
            bytes = new byte[fs.available()];
            fs.read(bytes);
            fs.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        Base64 base64 = new Base64();
        String base64Sign = base64.encodeToString(bytes);
        return base64Sign;
    }

 

你可能感兴趣的:(文件转base64编码)