Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 비트코인
- EC2
- jQuery
- Ajax
- Spring
- AWS
- 암호화
- 블록체인
- phaser
- 웹게임
- Servlet
- RDS
- Cookie
- 도커
- express
- 웹소켓
- docker
- 배포
- CSS
- websocket
- autowired
- JavaScript
- tiles.xml
- SQL
- JSP
- node.js
- PL/SQL
- HTML
- 알고리즘
- model1
Archives
- Today
- Total
記錄
JAVA) CMD내 TREE 기능 구현 본문
package MakeDos;
import java.io.*;
import java.util.*;
public class Functions {
List<ArrayList> dirNames_arr;
public void showTree(File f) {
List<Integer> dirindexlist = new ArrayList();
dirNames_arr = new ArrayList();
List<String> dirNames = new ArrayList();
List<File> dirFiles = new ArrayList();
File[] files = f.listFiles();
// 파라미터로 받은 디렉토리 하위의 모든 폴더에 대한 인덱스값 catch
int tempindex = 0;
for (File temp : files) {
if (temp.isDirectory()) {
dirindexlist.add(tempindex);
}
tempindex++;
}
// catch한 인덱스값을 이용하여 폴더들 이름을 ArrayList에 add
// node 생성을 위한 arr에 add
for (int i = 0; i < dirindexlist.size(); i++) {
dirNames.add(files[(dirindexlist.get(i))].getName());
dirNames_arr.add((ArrayList) dirNames);
}
// catch한 인덱스값을 이용하여 폴더들을 ArrayList에 File로 add
for (int i = 0; i < dirindexlist.size(); i++) {
dirFiles.add(files[(dirindexlist.get(i))]);
}
String nodes = "";
while (true) {
if (f.getParentFile() != null) {
nodes += "";
if (f.getParentFile().getParentFile() != null) {
nodes += "\t";
if (f.getParentFile().getParentFile().getParentFile() != null) {
nodes += "\t";
}
}
}
break;
} // end - while
// 출력
for (int i = 0; i < dirNames.size(); i++) {
System.out.print(nodes);
System.out.println(dirNames.get(i));
showTree(dirFiles.get(i));
}
} // end - showTree
// public void tet(File ff) {
// System.out.println(ff.getParentFile().getParentFile().getName());
// }
} // end - class
package MakeDos;
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Functions fcs = new Functions();
File f = new File("C:\\Temp");
fcs.showTree(f);
} // end-main
} // end-class
![](http://cafefiles.naver.net/MjAxODAyMTlfMTUx/MDAxNTE5MDI0MDEyMjk2.XcHIndM6DyaVILj13qQ68LM0MJj5zlLbmoDXNGwA92kg.dWbIVyu13gaaJje6g1zz_DnHH2GNEhsiE9G3xBPYkz4g.JPEG.surhommekim/K-001.jpg)
![](http://cafefiles.naver.net/MjAxODAyMTlfMjY4/MDAxNTE5MDI0Mzg3NjE1.WfM6sa9IoTM50ve2xcoHyaiWg5buk0rj-8wYbDOu6Hkg.MdnTWKBlTO_fU6933L0EfXEFoGhFpVj-eeBT4r7cwIgg.JPEG.surhommekim/K-003.jpg)
'Computer language > JAVA' 카테고리의 다른 글
JAVA) Thread (0) | 2018.02.20 |
---|---|
JAVA) 직렬화 (0) | 2018.02.20 |
JAVA) Map.Entry와 entrySet() (1) | 2018.02.14 |
JAVA) Stream (0) | 2018.02.14 |
JAVA) ' .equlas ' 와 ' == ' 의 차이 (0) | 2018.02.13 |
Comments