1 package org
.spearce
.jgit
.lib
;
4 import java
.io
.FileOutputStream
;
5 import java
.io
.IOException
;
6 import java
.io
.InputStream
;
8 public class CopyTreeToDirectory
extends TreeVisitor
{
9 private final byte[] copyBuffer
= new byte[8192];
13 public CopyTreeToDirectory(final File x
) {
17 protected void visitTree(final Tree t
) throws IOException
{
22 final File d
= new File(dest
, t
.getName());
31 protected void visitFile(final FileTreeEntry f
) throws IOException
{
32 final File d
= new File(dest
, f
.getName());
33 final ObjectReader or
= f
.openBlob();
36 throw new MissingObjectException(Constants
.TYPE_BLOB
, f
.getId());
38 is
= or
.getInputStream();
40 final FileOutputStream fos
= new FileOutputStream(d
);
43 while ((r
= is
.read(copyBuffer
)) > 0) {
44 fos
.write(copyBuffer
, 0, r
);