public static void closeAllStreams(InputStream input, OutputStream output){ closeInputStream(input); closeOutputStream(output); }
public static void closeAllStreams(InputStream input, OutputStream output){ closeInputStream(input); closeOutputStream(output); }
public static void closeAllStreams(InputStream input, OutputStream output){ closeInputStream(input); closeOutputStream(output); }
private byte[] getBytesFromFile(File file) throws java.lang.Exception { InputStream is = new FileInputStream(file); try { // Get the size of the file long length = file.length(); if (length > Integer.MAX_VALUE) { throw new IOException("File is too large"); } // Create the byte array to hold the data byte[] bytes = new byte[(int) length]; // Read in the bytes int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) { offset += numRead; } if (offset < bytes.length) { throw new IOException("Could not completely read file " + file.getName()); } return bytes; } catch (java.lang.Exception e) { log.error("Error in getting bytes from file.", e); throw e; } finally { IdentityIOStreamUtils.closeInputStream(is); } }
private byte[] getBytesFromFile(File file) throws java.lang.Exception { InputStream is = new FileInputStream(file); try { // Get the size of the file long length = file.length(); if (length > Integer.MAX_VALUE) { throw new IOException("File is too large"); } // Create the byte array to hold the data byte[] bytes = new byte[(int) length]; // Read in the bytes int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) { offset += numRead; } if (offset < bytes.length) { throw new IOException("Could not completely read file " + file.getName()); } return bytes; } catch (java.lang.Exception e) { log.error("Error in getting bytes from file.", e); throw e; } finally { IdentityIOStreamUtils.closeInputStream(is); } }
configHolder.getPolicySchemaMap().put(schemaNS, schema); } finally { IdentityIOStreamUtils.closeInputStream(schemaFileStream);
configHolder.getPolicySchemaMap().put(schemaNS, schema); } finally { IdentityIOStreamUtils.closeInputStream(schemaFileStream);
configHolder.getPolicySchemaMap().put(schemaNS, schema); } finally { IdentityIOStreamUtils.closeInputStream(schemaFileStream);
public Workbook createWorkbook() throws UserAdminException { String filename = config.getFileName(); InputStream ins = config.getInStream(); Workbook wb = null; try { if (filename.endsWith(".xlsx")) { wb = new XSSFWorkbook(ins); } else { POIFSFileSystem fs = new POIFSFileSystem(ins); wb = new HSSFWorkbook(fs); } } catch (Exception e) { log.error("Bulk import failed" + e.getMessage(), e); throw new UserAdminException("Bulk import failed" + e.getMessage(), e); } finally { IdentityIOStreamUtils.closeInputStream(ins); } return wb; }
IdentityIOStreamUtils.closeInputStream(stream);
/** * Generate a WorkBook object from the excel file. * * @return : The generated workbook * @throws UserAdminException : Throws if there is any error occurred in the process of creating the workbook. */ private Workbook createWorkbook() throws UserAdminException { String filename = config.getFileName(); InputStream ins = config.getInStream(); Workbook wb; try { if (filename.endsWith(".xlsx")) { wb = new XSSFWorkbook(ins); } else { POIFSFileSystem fs = new POIFSFileSystem(ins); wb = new HSSFWorkbook(fs); } } catch (IOException e) { throw new UserAdminException("Error reading the xls file " + e.getMessage(), e); } finally { IdentityIOStreamUtils.closeInputStream(ins); } return wb; } }
IdentityIOStreamUtils.closeInputStream(stream);
/** * Initializes the XML Document object * * @param absoluteFilePath xml path * @return OMElement object will be returned */ private OMElement initializeOMElement(String absoluteFilePath) throws UserStoreConfigurationDeployerException { StAXOMBuilder builder; InputStream inStream = null; try { inStream = new FileInputStream(absoluteFilePath); builder = new StAXOMBuilder(inStream); return builder.getDocumentElement(); } catch (FileNotFoundException e) { String errMsg = " Secondary storage file Not found in given repo " + absoluteFilePath; throw new UserStoreConfigurationDeployerException(errMsg, e); } catch (XMLStreamException e) { String errMsg = " Secondary storage file reading for repo = " + absoluteFilePath + " failed "; throw new UserStoreConfigurationDeployerException(errMsg, e); } finally { IdentityIOStreamUtils.closeInputStream(inStream); } }
IdentityIOStreamUtils.closeInputStream(fis);
IdentityIOStreamUtils.closeInputStream(fis);