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); } }
public static void closeAllStreams(InputStream input, OutputStream output){ closeInputStream(input); closeOutputStream(output); }
private String sendRequest(String url) throws IOException { BufferedReader in = null; StringBuilder b = new StringBuilder(); try{ URLConnection urlConnection = new URL(url).openConnection(); in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), Charset.forName("utf-8"))); String inputLine = in.readLine(); while (inputLine != null) { b.append(inputLine).append("\n"); inputLine = in.readLine(); } } finally { IdentityIOStreamUtils.closeReader(in); } return b.toString(); }
throw new SecurityException("msg", e); } finally { IdentityIOStreamUtils.flushOutputStream(outStream); IdentityIOStreamUtils.closeOutputStream(outStream);
throw new DeploymentException(errMsg, e); } finally { IdentityIOStreamUtils.closeOutputStream(outputStream);
throw new SecurityException("msg", e); } finally { IdentityIOStreamUtils.flushOutputStream(outStream); IdentityIOStreamUtils.closeOutputStream(outStream);
throw new DeploymentException(errMsg, e); } finally { IdentityIOStreamUtils.closeOutputStream(outputStream);
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); } }
public static void closeAllStreams(InputStream input, OutputStream output){ closeInputStream(input); closeOutputStream(output); }
throw new SecurityException("msg", e); } finally { IdentityIOStreamUtils.flushOutputStream(outStream); IdentityIOStreamUtils.closeOutputStream(outStream);
protected String sendRequest(String url) throws IOException { BufferedReader in = null; StringBuilder b = new StringBuilder(); try { URLConnection urlConnection = new URL(url).openConnection(); in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), Charset.forName("utf-8"))); String inputLine = in.readLine(); while (inputLine != null) { b.append(inputLine).append("\n"); inputLine = in.readLine(); } } finally { IdentityIOStreamUtils.closeReader(in); } return b.toString(); }
configHolder.getPolicySchemaMap().put(schemaNS, schema); } finally { IdentityIOStreamUtils.closeInputStream(schemaFileStream);
public static void closeAllStreams(InputStream input, OutputStream output){ closeInputStream(input); closeOutputStream(output); }
log.error("Error while generating private key file object", e); }finally { IdentityIOStreamUtils.flushOutputStream(fos); IdentityIOStreamUtils.closeOutputStream(fos);
private String sendRequest(String url) throws IOException { BufferedReader in = null; StringBuilder b = new StringBuilder(); try{ URLConnection urlConnection = new URL(url).openConnection(); in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), Charset.forName("utf-8"))); String inputLine = in.readLine(); while (inputLine != null) { b.append(inputLine).append("\n"); inputLine = in.readLine(); } } finally { IdentityIOStreamUtils.closeReader(in); } return b.toString(); }
configHolder.getPolicySchemaMap().put(schemaNS, schema); } finally { IdentityIOStreamUtils.closeInputStream(schemaFileStream);
log.error("Error while generating private key file object", e); } finally { IdentityIOStreamUtils.flushOutputStream(fos); IdentityIOStreamUtils.closeOutputStream(fos);
@Override protected String sendRequest(String url, String accessToken) throws IOException { if (!StringUtils.isBlank(url) && !StringUtils.isBlank(accessToken)) { String finalUrl = url + accessToken; URLConnection urlConnection = new URL(finalUrl).openConnection(); BufferedReader reader = new BufferedReader( new InputStreamReader(urlConnection.getInputStream(), Charset.forName("utf-8"))); StringBuilder builder = new StringBuilder(); try { String inputLine = reader.readLine(); while (inputLine != null) { builder.append(inputLine).append("\n"); inputLine = reader.readLine(); } }finally { IdentityIOStreamUtils.closeReader(reader); } return builder.toString(); } else { return StringUtils.EMPTY; } } }
configHolder.getPolicySchemaMap().put(schemaNS, schema); } finally { IdentityIOStreamUtils.closeInputStream(schemaFileStream);
@Override protected String sendRequest(String url, String accessToken) throws IOException { if (!StringUtils.isBlank(url) && !StringUtils.isBlank(accessToken)) { String finalUrl = url + accessToken; URLConnection urlConnection = new URL(finalUrl).openConnection(); BufferedReader reader = new BufferedReader( new InputStreamReader(urlConnection.getInputStream(), Charset.forName("utf-8"))); StringBuilder builder = new StringBuilder(); try { String inputLine = reader.readLine(); while (inputLine != null) { builder.append(inputLine).append("\n"); inputLine = reader.readLine(); } }finally { IdentityIOStreamUtils.closeReader(reader); } return builder.toString(); } else { return StringUtils.EMPTY; } } }