Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String uploadFile(UploadedFile doc) {
- UploadedFile myDoc = doc;
- String path = null;
- if (myDoc == null) {
- } else {
- InputStream inputStream = null;
- try {
- String dateAddition = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new java.util.Date());
- String ocLogos = BuildixxUtils.EXTERNAL_IMAGE_DIR + "operation_center_logos" + File.separator;
- String reportLogos = BuildixxUtils.EXTERNAL_IMAGE_DIR + "report_logos" + File.separator;
- if (this.ocLogo) {
- path = ocLogos + dateAddition + "_" + myDoc.getFilename();
- } else {
- DCIteratorBinding operationCenterIterator =
- ADFUtils.findIterator("OperationCenterForUserAdminCenterView1Iterator");
- Row currentOperationCenterRow = operationCenterIterator.getCurrentRow();
- path = reportLogos + (String)currentOperationCenterRow.getAttribute("GSymbol");
- }
- System.out.println(path + " PATH + FILENAME ");
- FileOutputStream out = new FileOutputStream(path);
- inputStream = myDoc.getInputStream();
- byte[] buffer = new byte[8192];
- int bytesRead = 0;
- while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
- out.write(buffer, 0, bytesRead);
- }
- out.flush();
- out.close();
- } catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- } finally {
- try {
- inputStream.close();
- } catch (IOException ioex) {
- log.error(ioex.getMessage(), ioex);
- }
- }
- }
- return path;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement