private Document readISDAsByteArray(byte[] data) { ByteArrayInputStream bas = null; BufferedInputStream bis = null; try { bas = new ByteArrayInputStream(data); bis = new BufferedInputStream(bas); return readISDFromStream(bis); } finally { IOUtil.closeSafely(bis); IOUtil.closeSafely(bas); } }
public static String getDirectoryPath(File f) { try { File d = getDirectory(f); return (d != null) ? d.getCanonicalPath() : null; } catch (IOException e) { return null; } }
reporterOutput = new PrintWriter(new BufferedWriter(new OutputStreamWriter(os, reporterFileEncoding))); } catch (Throwable e) { IOUtil.closeSafely(os); if (createdReporterFile) IOUtil.deleteSafely(reporterFile); reporterOutput.close(); if (createdReporterFile) IOUtil.deleteSafely(reporterFile);
bis = new BufferedInputStream(audio.getURI().toURL().openStream()); byte[] buf = new byte[signatureLengthMaximum]; int nb = IOUtil.readCompletely(bis, buf); for (Signature s : signatures) { MimeType mtSniffed = sniffAudio(buf, nb, s.getSignature(), s.getType()); failed = true; } finally { IOUtil.closeSafely(bis);
reporterOutput = new PrintWriter(new BufferedWriter(new OutputStreamWriter(os, reporterFileEncoding))); } catch (Throwable e) { IOUtil.closeSafely(os); if (createdReporterFile) IOUtil.deleteSafely(reporterFile); reporterOutput.close(); if (createdReporterFile) IOUtil.deleteSafely(reporterFile);
bis = new BufferedInputStream(image.getURI().toURL().openStream()); byte[] buf = new byte[signatureLengthMaximum]; int nb = IOUtil.readCompletely(bis, buf); for (Signature s : signatures) { MimeType mtSniffed = sniffImage(buf, nb, s.getSignature(), s.getType()); failed = true; } finally { IOUtil.closeSafely(bis);
private Object writeISDAsByteArray(Document document, int sequenceIndex, TransformerContext context) { Reporter reporter = context.getReporter(); ByteArrayOutputStream bas = null; BufferedOutputStream bos = null; try { bas = new ByteArrayOutputStream(); bos = new BufferedOutputStream(bas); writeISD(document, bos, context); return bas.toByteArray(); } catch (Exception e) { reporter.logError(e); return null; } finally { IOUtil.closeSafely(bos); IOUtil.closeSafely(bas); } }
bis = new BufferedInputStream(font.getURI().toURL().openStream()); byte[] buf = new byte[signatureLengthMaximum]; int nb = IOUtil.readCompletely(bis, buf); for (Signature s : signatures) { MimeType mtSniffed = sniffFont(buf, nb, s.getSignature(), s.getType()); failed = true; } finally { IOUtil.closeSafely(bis);
if (!outputFile.isAbsolute()) outputFile = new File(".", outputFilePath); File outputFileDirectory = IOUtil.getDirectory(outputFile); if ((outputFileDirectory == null) || !outputFileDirectory.exists()) throw new InvalidOptionUsageException("output-file", reporter.message("x.018", "directory does not exist: {0}", outputFile.getPath()));
private ByteBuffer readResource(URI uri) { Reporter reporter = getReporter(); ByteArrayOutputStream os = new ByteArrayOutputStream(); InputStream is = null; try { is = uri.toURL().openStream(); byte[] buffer = new byte[1024]; int nb; while ((nb = is.read(buffer)) >= 0) { os.write(buffer, 0, nb); } } catch (IOException e) { reporter.logError(e); os = null; } finally { IOUtil.closeSafely(is); } return (os != null) ? ByteBuffer.wrap(os.toByteArray()) : null; }
private Document readISDAsFile(File data) { FileInputStream fis = null; BufferedInputStream bis = null; try { fis = new FileInputStream(data); bis = new BufferedInputStream(fis); return readISDFromStream(bis); } catch (IOException e) { getContext().getReporter().logError(e); return null; } finally { IOUtil.closeSafely(bis); IOUtil.closeSafely(fis); } }
private ByteBuffer readResource(URI uri) { Reporter reporter = getReporter(); ByteArrayOutputStream os = new ByteArrayOutputStream(); InputStream is = null; try { is = getInputStream(uri); byte[] buffer = new byte[1024]; int nb; while ((nb = is.read(buffer)) >= 0) { os.write(buffer, 0, nb); } } catch (IOException e) { reporter.logError(e); os = null; } finally { IOUtil.closeSafely(is); } return (os != null) ? ByteBuffer.wrap(os.toByteArray()) : null; }
private Object writeISDAsFile(Document document, int sequenceIndex, TransformerContext context) { Reporter reporter = context.getReporter(); FileOutputStream fos = null; BufferedOutputStream bos = null; try { String outputFileName = outputPatternFormatter.format(new Object[]{Integer.valueOf(sequenceIndex)}); File outputFile = new File(outputDirectory, outputFileName); fos = new FileOutputStream(outputFile); bos = new BufferedOutputStream(fos); writeISD(document, bos, context); reporter.logInfo(reporter.message("*KEY*", "Wrote ISD ''{0}''.", outputFile.getAbsolutePath())); return outputFile; } catch (FileNotFoundException e) { reporter.logError(e); return null; } finally { IOUtil.closeSafely(bos); IOUtil.closeSafely(fos); } }
return false; } finally { IOUtil.closeSafely(bis);
return false; } finally { IOUtil.closeSafely(bis);
return false; } finally { IOUtil.closeSafely(bis);