@@ -0,0 +1,1308 @@
+package jp.naist.sd.kenja.factextractor;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0A%0A%0Aimport com.google.common.base.Charsets;%0Aimport com.google.common.io.Files;%0A%0Apublic class TreeWriter %7B%0A%0A%09private File baseDir;%0A%09private File currentDir;%0A%0A%09public TreeWriter(File baseDir) %7B%0A%09%09this.baseDir = baseDir;%0A%09%09if (!baseDir.exists()) %7B%0A%09%09%09try %7B%0A%09%09%09%09Files.createParentDirs(baseDir);%0A%09%09%09%09baseDir.mkdir();%0A%09%09%09%7D catch (IOException e) %7B%0A%09%09%09%09// TODO Auto-generated catch block%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09public void writeTree(Tree tree) %7B%0A%09%09if (!tree.isRoot()) %7B%0A%09%09%09currentDir = new File(baseDir, tree.getName());%0A%09%09%09if (!currentDir.exists())%0A%09%09%09%09currentDir.mkdir();%0A%09%09%7D%0A%0A%09%09for (Blob blob : tree.getBlobs()) %7B%0A%09%09%09writeBlob(blob);%0A%09%09%7D%0A%0A%09%09for (Tree childTree : tree.getChildTrees()) %7B%0A%09%09%09writeTree(childTree);%0A%09%09%7D%0A%09%7D%0A%0A%09public void writeBlob(Blob blob) %7B%0A%09%09if (!currentDir.exists())%0A%09%09%09try %7B%0A%09%09%09%09Files.createParentDirs(currentDir);%0A%09%09%09%09currentDir.mkdir();%0A%09%09%09%7D catch (IOException e) %7B%0A%09%09%09%09// TODO Auto-generated catch block%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09File blobFile = new File(currentDir, blob.getName());%0A%09%09try %7B%0A%09%09%09blobFile.createNewFile();%0A%09%09%09Files.write(blob.getBody(), blobFile, Charsets.US_ASCII);%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09// TODO Auto-generated catch block%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%7D%0A%7D%0A

add TreeWriter.java