public void close() { Safe.close(context); } }
public static boolean notEquals(Object o1, Object o2) { return !equals(o1, o2); }
public void file(String fileName, int length, InputStream data) throws IOException { try { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(true); SAXParser parser = factory.newSAXParser(); parser.parse(data, attributesHandler); } catch (Exception e) { Safe.rethrow(IOException.class, e); } }
public void run() { try { processor.provide(Text.create(message)); } catch (IOException e) { // todo ??? e.printStackTrace(); } finally { // Be sure to flush Safe.flush(processor.term); } } };
public void file(String fileName, int length, InputStream data) throws IOException { try { session.getWorkspace().importXML(path, data, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING); } catch (RepositoryException e) { Safe.rethrow(IOException.class, e); } } public void endDirectory(String directoryName) throws IOException {
public void endDirectory(String directoryName) throws IOException { try { EndElement end = stack.removeLast(); handler.endElement(end.uri, end.localName, end.qName); if (stack.isEmpty()) { for (String prefix : prefixes) { log.log(Level.FINE, "Removing prefix mapping " + prefix); handler.endPrefixMapping(prefix); } prefixes.clear(); } } catch (Exception e) { Safe.rethrow(IOException.class, e); } }
public void close() { if (closed.compareAndSet(false, true)) { for (Closeable closeable : closeables) { log.log(Level.FINE, "Closing " + closeable.getClass().getSimpleName()); Safe.close(closeable); } } } }
public static void copy(InputStream in, OutputStream out) throws IOException { if (in == null) { throw new NullPointerException(); } try { byte[] buffer = new byte[256]; for (int l = in.read(buffer); l != -1; l = in.read(buffer)) { out.write(buffer, 0, l); } } finally { Safe.close(in); } }
@Override ShellResponse doInvoke(final ShellProcessContext context) throws InterruptedException { CRaSHProcessContext invocationContext = new CRaSHProcessContext(CRaSHSession.this, context); try { pipeLine.open(invocationContext); pipeLine.flush(); return ShellResponse.ok(); } catch (ScriptException e) { return build(e); } catch (Throwable t) { return build(t); } finally { Safe.close(pipeLine); Safe.close(invocationContext); } }
Safe.close(container);
Object dispatch(String methodName, Object[] arguments) { PipeCommandProxy pipe = resolvePipe(methodName, arguments, false); // try { pipe.fire(); return null; } catch (ScriptException e) { Throwable cause = e.getCause(); if (cause != null) { throw new InvokerInvocationException(cause); } else { throw e; } } finally { Safe.close(pipe); } }
Safe.close(closeable);