public String saveToFile(String hexValue, ComparisonManager comparisonManager,String flag)
{
BufferedOutputStream bos = null;
FileOutputStream fos = null;
File file = null;
String filename = "";
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
String result = date + File.separator + String.valueOf(System.currentTimeMillis()) + "%s.jpg";
result=String.format(result,flag);
try {
byte[] b = Base64.getMimeDecoder().decode(hexValue);
String uploadDir = String.format(
"%s/%s/",
appProperty.getUploadPath(),
date
);
File folder = new File(uploadDir);
if (!folder.exists() && !folder.isDirectory()) {
folder.mkdirs();
}
filename = appProperty.getUploadPath()+File.separator + result;
file = new File(filename);
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
bos.write(b);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bos != null) {
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return result;
}