@Override public void close() throws IOException { IOUtils.closeQuietly(inputStream); } }
@Override public void close() throws IOException { IOUtils.closeQuietly(inputStream); } }
@Override public void close() throws IOException { if (is != null) { IOUtils.closeQuietly(is); } }
/** * Close the streams which has been opened when getting the InputStream using * {@link #getInputStream()}. All the input streams are closed at the end of the request. This * is done when the FileUploadField, which is associated with this FileUpload is detached. * <p> * If an exception is thrown when closing the input streams, we ignore it, because the stream * might have been closed already. */ public final void closeStreams() { if (inputStreamsToClose != null) { for (InputStream inputStream : inputStreamsToClose) { IOUtils.closeQuietly(inputStream); } // Reset the list inputStreamsToClose = null; } }
/** * Close the streams which has been opened when getting the InputStream using * {@link #getInputStream()}. All the input streams are closed at the end of the request. This * is done when the FileUploadField, which is associated with this FileUpload is detached. * <p> * If an exception is thrown when closing the input streams, we ignore it, because the stream * might have been closed already. */ public final void closeStreams() { if (inputStreamsToClose != null) { for (InputStream inputStream : inputStreamsToClose) { IOUtils.closeQuietly(inputStream); } // Reset the list inputStreamsToClose = null; } }
/** * Writes the input stream to the output stream. Input is done without a Reader object, meaning * that the input is copied in its raw form. After it is copied it will close the streams. * * @param in * The input stream * @param out * The output stream * @return Number of bytes copied from one stream to the other * @throws IOException */ public static int copyAndClose(final InputStream in, final OutputStream out) throws IOException { try { return copy(in, out); } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); } }
/** * Checks whether a CKEditor resource reference exists on the class path. * @param ref a CKEditor resource reference. */ static boolean existsOnClassPath(final UrlResourceReference ref) { final String path = ref.getUrl().getPath(); final InputStream resource = CKEditorConstants.class.getResourceAsStream("/" + path); IOUtils.closeQuietly(resource); return resource != null; }
IOUtils.closeQuietly(lineNumberReader); IOUtils.closeQuietly(inputStream); IOUtils.closeQuietly(inputStreamReader);
private ImageInfo createImageInfo() throws GalleryException { InputStream stream = null; try { Map<String, Object> params = new HashMap<>(); //If an image contains a corrupt thumbnail it will throw an error reading metadata, so skip it. //See https://issues.apache.org/jira/browse/IMAGING-50?focusedCommentId=13162306&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13162306 params.put(Sanselan.PARAM_KEY_READ_THUMBNAILS, Boolean.FALSE); stream = getStream(); return Sanselan.getImageInfo(stream, fileName, params); } catch (ImageReadException | IOException | RepositoryException e) { die("Failed to create Sanselan image info", e); } finally { IOUtils.closeQuietly(stream); } throw new IllegalStateException("No way"); }
@Override public void destroy() { try { super.destroy(); if (task != null) { task.interrupt(); } } finally { IOUtils.closeQuietly(watchService); } }
@Override public void destroy() { try { super.destroy(); if (task != null) { task.interrupt(); } } finally { IOUtils.closeQuietly(watchService); } }
private boolean isYCCK() throws RepositoryException { InputStream stream = getStream(); try { Set<JpegSegmentType> segmentTypes = new HashSet<>(); segmentTypes.add(JpegSegmentType.APPE); JpegSegmentData segmentData = JpegSegmentReader.readSegments(new StreamReader(stream), segmentTypes); byte[] appe = segmentData.getSegment(JpegSegmentType.APPE); return appe != null && appe[11] == 2; } catch (IOException | JpegProcessingException e1) { log.warn("Unable to read color space", e1); } finally { IOUtils.closeQuietly(stream); } return false; }
/** * Closes this resource. * * @throws IOException */ @Override public void close() throws IOException { StreamData data = getData(false); if (data != null) { Connections.closeQuietly(data.connection); if (data.inputStreams != null) { for (InputStream is : data.inputStreams) { IOUtils.closeQuietly(is); } } streamData = null; } }
/** * Closes this resource. * * @throws IOException */ @Override public void close() throws IOException { StreamData data = getData(false); if (data != null) { Connections.closeQuietly(data.connection); if (data.inputStreams != null) { for (InputStream is : data.inputStreams) { IOUtils.closeQuietly(is); } } streamData = null; } }
/** * Reads and parses markup from an input stream. * <p> * Note: The input is closed after parsing. * * @param inputStream * The input stream to read and parse * @param encoding * The default character encoding of the input * @throws IOException */ @Override public void parse(final InputStream inputStream, final String encoding) throws IOException { Args.notNull(inputStream, "inputStream"); try { XmlReader xmlReader = new XmlReader(new BufferedInputStream(inputStream, 4000), encoding); this.input = new FullyBufferedReader(xmlReader); this.encoding = xmlReader.getEncoding(); } finally { IOUtils.closeQuietly(inputStream); } }
/** * Reads and parses markup from an input stream. * <p> * Note: The input is closed after parsing. * * @param inputStream * The input stream to read and parse * @param encoding * The default character encoding of the input * @throws IOException */ @Override public void parse(final InputStream inputStream, final String encoding) throws IOException { Args.notNull(inputStream, "inputStream"); try { XmlReader xmlReader = new XmlReader(new BufferedInputStream(inputStream, 4000), encoding); this.input = new FullyBufferedReader(xmlReader); this.encoding = xmlReader.getEncoding(); } finally { IOUtils.closeQuietly(inputStream); } }
IOUtils.closeQuietly(inputStream);
@Override public String asText() { InputStream stream = null; try { stream = getInputStream(); return IOUtils.toString(stream, Bootstrap.getSettings(Application.get()).getBootstrapLessCompilerSettings().getCharset().name()); } catch (IOException e) { throw new WicketRuntimeException(e); } finally { IOUtils.closeQuietly(stream); } }
@Override public void writeData(final Attributes attributes) throws IOException { try { InputStream inputStream = webExternalResourceStream.getInputStream(); try { Streams.copy(inputStream, attributes.getResponse().getOutputStream()); } finally { IOUtils.closeQuietly(inputStream); } } catch (ResourceStreamNotFoundException rsnfx) { throw new WicketRuntimeException(rsnfx); } } });
@Override public void writeData(final Attributes attributes) throws IOException { try { InputStream inputStream = webExternalResourceStream.getInputStream(); try { Streams.copy(inputStream, attributes.getResponse().getOutputStream()); } finally { IOUtils.closeQuietly(inputStream); } } catch (ResourceStreamNotFoundException rsnfx) { throw new WicketRuntimeException(rsnfx); } } });