public String fileUpload() throws WebException {
FileInputStream fin = null;
try {
fin = new FileInputStream(getImg());
byte fileContent[] = new byte[(int)getImg().length()];
getPushItem().setImg(new String(Base64.encodeBase64(fileContent)));
} catch (FileNotFoundException e) {
log.error("Error " + e);
}
finally {
try {
if (fin != null) {
fin.close();
}
}
catch (IOException ioe) {
log.error("Error while closing stream: " + ioe);
}
}
return "success";
}
FileInputStream fin = null;
try {
fin = new FileInputStream(getImg());
byte fileContent[] = new byte[(int)getImg().length()];
getPushItem().setImg(new String(Base64.encodeBase64(fileContent)));
} catch (FileNotFoundException e) {
log.error("Error " + e);
}
finally {
try {
if (fin != null) {
fin.close();
}
}
catch (IOException ioe) {
log.error("Error while closing stream: " + ioe);
}
}
return "success";
}
No comments:
Post a Comment