Return-Path: Delivered-To: apmail-jackrabbit-users-archive@minotaur.apache.org Received: (qmail 6734 invoked from network); 28 Jul 2009 21:10:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Jul 2009 21:10:16 -0000 Received: (qmail 63878 invoked by uid 500); 28 Jul 2009 21:02:56 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 63837 invoked by uid 500); 28 Jul 2009 21:02:56 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 63826 invoked by uid 99); 28 Jul 2009 21:02:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 21:02:56 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [76.13.9.30] (HELO web65410.mail.ac4.yahoo.com) (76.13.9.30) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 28 Jul 2009 21:02:45 +0000 Received: (qmail 25528 invoked by uid 60001); 28 Jul 2009 21:02:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1248814944; bh=6zKsk65jCGifSj0nEek3Y1l4RGoLfyKdGEErkoKVI1U=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=c3dz6MMw+dh80ui6nrC6Ezeo0VEaB/wPCWVtNdYzDre1LA4ewZM+KhK61g/LxQWLmbdb9RIYvtjyBKOZnQUnHqpMRfLaeUMR90rYM7kEryfnjs5EPKT8RoOdB64CTIn60JUBfzMrm6IoBknoMD5pmNpS4amKfREYR2lo0aXcdNw= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=GQNDLO2KcGqGJq+Tw5xMqQltqPoSBLCxBDpEqN+k2EPYYOaCgsBx5KvKmEnORAfgW3mQgVwaDMRvekbVzNI3uyYUco+ABpgjGzqO1Xk5/NcRMPrQUc4DdEjn5Yq8lwsh2zOec1zNvITtkeY8+mGOMUtx+xvtZNbhaKags+YaFe8=; Message-ID: <225140.25445.qm@web65410.mail.ac4.yahoo.com> X-YMail-OSG: q_iH_44VM1nEcNvCIY3wohIJQmihhdvsNCPBtbU6pl_p3tdFE43uOUwB_rIAFgnkSqui8327OsfsB6tTiSk_xjWRaPPgsoGOLr5ENUYNHzHVOgBZIXLatb7P8wfK4bkFJS6XD9_JcYLB_gNiU_00ZJEKXNDX3lfHyqwJXRFTioV8Kqzd6Q.5iR4S_4I6AvgBQMWap9g_HnG4i1vPvYqUZfPYO4WGxWOdDusXaOZsvQM9vsSSX9RMOXfqU42kDeq_TMMhS26nJeSl2_h_PODnZG2hAkzBnagzvTGOoNdUqQ-- Received: from [121.96.190.56] by web65410.mail.ac4.yahoo.com via HTTP; Tue, 28 Jul 2009 14:02:23 PDT X-Mailer: YahooMailRC/1358.22 YahooMailWebService/0.7.338.1 Date: Tue, 28 Jul 2009 14:02:23 -0700 (PDT) From: Fernando Cabredo Subject: Using InputStream To: users@jackrabbit.apache.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-205221969-1248814943=:25445" X-Virus-Checked: Checked by ClamAV on apache.org --0-205221969-1248814943=:25445 Content-Type: text/plain; charset=us-ascii Hi, I have the code below which lists files under a folder node and copy the files into my c:\ drive. However, I am not getting right the use of InputStream and FileOutputStream.this is why the file that is being copied into my c:\ is incorrect. Can anybody please help me on this? Thank you. Fernando Cabredo ----------------------------------------------------------------------------------------------------- String nodeType; Node n; Node root = session.getRootNode(); if(selectedNode.equals("")){ n = root; }else{ selectedNode = selectedNode.substring(1, selectedNode.length()); n = root.getNode(selectedNode); } NodeIterator nodes = n.getNodes(); System.out.println("Listing Files of Folder Nodes under ---->"+ n.getName()); while (nodes.hasNext()) { Node node; node = nodes.nextNode(); String nodename = node.getName(); nodeType = node.getProperty("jcr:primaryType").getString(); if (nodeType.equals("nt:file")) { System.out.println("Node name ----->"+nodename); InputStream attachFileIS = null; Node resNode = node.getNode("jcr:content"); Value attachFileValue = resNode.getProperty("jcr:data").getValue(); attachFileIS = attachFileValue.getStream(); fout = new FileOutputStream("c://"+nodename); byte[] readData = new byte[1024]; int i = attachFileIS.read(readData); while (i != -1) { fout.write(i); i = attachFileIS.read(readData); } fout.close(); } //aList.add(nodeProperty); } }catch (Exception e) { e.printStackTrace(); } --0-205221969-1248814943=:25445--