|
|
|
@ -1,13 +1,14 @@
|
|
|
|
|
package cokr.xit.fims.cmmn;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class DirectoryStructureToJson {
|
|
|
|
|
|
|
|
|
|
public static Node getNode(File fileNode){
|
|
|
|
|
if(fileNode.isDirectory()){
|
|
|
|
|
public static Node getNode(File fileNode) throws IOException{
|
|
|
|
|
if(fileNode.getCanonicalFile().isDirectory()){
|
|
|
|
|
return new Node(fileNode.getName(),fileNode.getAbsolutePath(),"directory", getDirList(fileNode));
|
|
|
|
|
}else{
|
|
|
|
|
return new Node(fileNode.getName(),fileNode.getAbsolutePath(),"file",null);
|
|
|
|
@ -15,7 +16,7 @@ public class DirectoryStructureToJson {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static List<Node> getDirList(File node){
|
|
|
|
|
public static List<Node> getDirList(File node) throws IOException{
|
|
|
|
|
List<Node> children=new ArrayList<>();
|
|
|
|
|
for(File n : node.listFiles()){
|
|
|
|
|
children.add(getNode(n));
|
|
|
|
|