/** * Writes the contents of file stored at the given node to the given * stream. Similar file handling logic is used as in the * {@link #readFile(Node)} method. * * @since Apache Jackrabbit 2.3 * @param node node to be read * @param output to which the file contents are written * @throws RepositoryException if the file can not be accessed * @throws IOException if the file can not be read or written */ public static void readFile(Node node, OutputStream output) throws RepositoryException, IOException { InputStream input = readFile(node); try { byte[] buffer = new byte[16 * 1024]; int n = input.read(buffer); while (n != -1) { output.write(buffer, 0, n); n = input.read(buffer); } } finally { input.close(); } }
/** * Writes the contents of file stored at the given node to the given * stream. Similar file handling logic is used as in the * {@link #readFile(Node)} method. * * @since Apache Jackrabbit 2.3 * @param node node to be read * @param output to which the file contents are written * @throws RepositoryException if the file can not be accessed * @throws IOException if the file can not be read or written */ public static void readFile(Node node, OutputStream output) throws RepositoryException, IOException { InputStream input = readFile(node); try { byte[] buffer = new byte[16 * 1024]; int n = input.read(buffer); while (n != -1) { output.write(buffer, 0, n); n = input.read(buffer); } } finally { input.close(); } }
/** * Writes the contents of file stored at the given node to the given * stream. Similar file handling logic is used as in the * {@link #readFile(Node)} method. * * @since Apache Jackrabbit 2.3 * @param node node to be read * @param output to which the file contents are written * @throws RepositoryException if the file can not be accessed * @throws IOException if the file can not be read or written */ public static void readFile(Node node, OutputStream output) throws RepositoryException, IOException { InputStream input = readFile(node); try { byte[] buffer = new byte[16 * 1024]; int n = input.read(buffer); while (n != -1) { output.write(buffer, 0, n); n = input.read(buffer); } } finally { input.close(); } }
@Override public void run() { try { String path = getRandomPath(); session.refresh(false); JcrUtils.readFile( session.getNode(path), new NullOutputStream()); } catch (Exception e) { e.printStackTrace(); } }
@Override public void run() { try { String path = getRandomReadPath(); session.refresh(false); JcrUtils.readFile( session.getNode(path), new NullOutputStream()); } catch (Exception e) { LOG.error("Exception in reader execution ", e); } }
return readFile(node.getNode(Node.JCR_CONTENT)); } else { throw new RepositoryException(
return readFile(node.getNode(Node.JCR_CONTENT)); } else { throw new RepositoryException(
return readFile(node.getNode(Node.JCR_CONTENT)); } else { throw new RepositoryException(