@Override public void close() throws IOException { delegate.close(); } }
delegate.close();
@Override public void close() throws IOException { delegate.close(); } }
@Nullable @Override public <T> ExternalResourceReadResult<T> withContentIfPresent(Transformer<? extends T, ? super InputStream> readAction) throws ResourceException { if (!localFile.exists()) { return null; } try { CountingInputStream input = new CountingInputStream(new BufferedInputStream(new FileInputStream(localFile))); try { T resourceReadResult = readAction.transform(input); return ExternalResourceReadResult.of(input.getCount(), resourceReadResult); } finally { input.close(); } } catch (IOException e) { throw ResourceExceptions.getFailed(getURI(), e); } }
@Override @Nullable public ExternalResourceReadResult<Void> writeToIfPresent(File destination) { if (!localFile.exists()) { return null; } try { CountingInputStream input = new CountingInputStream(new FileInputStream(localFile)); try { FileOutputStream output = new FileOutputStream(destination); try { IOUtils.copyLarge(input, output); } finally { output.close(); } } finally { input.close(); } return ExternalResourceReadResult.of(input.getCount()); } catch (IOException e) { throw ResourceExceptions.getFailed(getURI(), e); } }
@Nullable @Override public <T> ExternalResourceReadResult<T> withContentIfPresent(ContentAction<? extends T> readAction) throws ResourceException { if (!localFile.exists()) { return null; } try { CountingInputStream input = new CountingInputStream(new BufferedInputStream(new FileInputStream(localFile))); try { T resourceReadResult = readAction.execute(input, getMetaData()); return ExternalResourceReadResult.of(input.getCount(), resourceReadResult); } finally { input.close(); } } catch (IOException e) { throw ResourceExceptions.getFailed(getURI(), e); } }
public ExternalResourceReadResult<Void> withContent(Action<? super InputStream> readAction) { if (!localFile.exists()) { throw ResourceExceptions.getMissing(getURI()); } try { CountingInputStream input = new CountingInputStream(new BufferedInputStream(new FileInputStream(localFile))); try { readAction.execute(input); } finally { input.close(); } return ExternalResourceReadResult.of(input.getCount()); } catch (IOException e) { throw ResourceExceptions.getFailed(getURI(), e); } }
termsList.close();
termsList.close();
@Override public ExternalResourceReadResult<Void> writeTo(OutputStream output) { if (!localFile.exists()) { throw ResourceExceptions.getMissing(getURI()); } try { CountingInputStream input = new CountingInputStream(new FileInputStream(localFile)); try { IOUtils.copyLarge(input, output); } finally { input.close(); } return ExternalResourceReadResult.of(input.getCount()); } catch (IOException e) { throw ResourceExceptions.getFailed(getURI(), e); } }
@Nullable @Override public ExternalResourceReadResult<Void> writeToIfPresent(File destination) throws ResourceException { try { ExternalResourceReadResponse response = accessor.openResource(name.getUri(), revalidate); if (response == null) { return null; } try { CountingInputStream input = new CountingInputStream(response.openStream()); try { FileOutputStream output = new FileOutputStream(destination); try { IOUtils.copyLarge(input, output); return ExternalResourceReadResult.of(input.getCount()); } finally { output.close(); } } finally { input.close(); } } finally { response.close(); } } catch (IOException e) { throw ResourceExceptions.getFailed(getURI(), e); } }
@Nullable @Override public <T> ExternalResourceReadResult<T> withContentIfPresent(Transformer<? extends T, ? super InputStream> transformer) throws ResourceException { try { ExternalResourceReadResponse response = accessor.openResource(name.getUri(), revalidate); if (response == null) { return null; } try { CountingInputStream input = new CountingInputStream(new BufferedInputStream(response.openStream())); try { T value = transformer.transform(input); return ExternalResourceReadResult.of(input.getCount(), value); } finally { input.close(); } } finally { response.close(); } } catch (IOException e) { throw ResourceExceptions.getFailed(name.getUri(), e); } }
@Nullable @Override public <T> ExternalResourceReadResult<T> withContentIfPresent(ContentAction<? extends T> readAction) throws ResourceException { try { ExternalResourceReadResponse response = accessor.openResource(name.getUri(), revalidate); if (response == null) { return null; } try { CountingInputStream stream = new CountingInputStream(new BufferedInputStream(response.openStream())); try { T value = readAction.execute(stream, response.getMetaData()); return ExternalResourceReadResult.of(stream.getCount(), value); } finally { stream.close(); } } finally { response.close(); } } catch (IOException e) { throw ResourceExceptions.getFailed(name.getUri(), e); } }
delegate.close();
stream.close();