我有以下代码将“rose.gif”插入roseNode。但是如何从存储库中检索文件?
Node roseNode = session.getRootNode().getNode("wiki:encyclopedia/wiki:entry[1]/");
File file = new File("rose.gif");
MimeTable mt = MimeTable.getDefaultTable();
String mimeType = mt.getContentTypeFor(file.getName());
if (mimeType == null) mimeType = "application/octet-stream";
Node fileNode = roseNode.addNode(file.getName(), "nt:file");
System.out.println( fileNode.getName() );
Node resNode = fileNode.addNode("jcr:content", "nt:resource");
resNode.setProperty("jcr:mimeType", mimeType);
resNode.setProperty("jcr:encoding", "");
resNode.setProperty("jcr:data", new FileInputStream(file));
Calendar lastModified = Calendar.getInstance();
lastModified.setTimeInMillis(file.lastModified());
resNode.setProperty("jcr:lastModified", lastModified);
//retrieve file and output as rose-out.gif
File outputFile = new File("rose-out.gif");
FileOutputStream out = new FileOutputStream(outputFile);