OutputStream ou = null;
InputStream in = null;
try {
in = new FileInputStream(sdPath + "/12.jpg");
byte[] buffer = new byte[1024 * 100];
int index = 0;
int length = 0;
while ((length = in.read(buffer)) != -1) {
File file = new File(sdPath + "/base64-" + index + ".txt");
if (!file.exists()) {
file.createNewFile();
}
ou = new FileOutputStream(file);
ou.write(Base64.encode(buffer, Base64.NO_PADDING));
index++;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
in.close();
ou.flush();
ou.close();
} catch (IOException e) {
e.printStackTrace();
}
}
android 图片转 Base64
最新推荐文章于 2024-07-10 03:10:36 发布