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