Skip to content

Commit

Permalink
클래스명을 좀더 행위에 맞는 이름으로 수정.
Browse files Browse the repository at this point in the history
  • Loading branch information
sangpire committed May 10, 2017
1 parent 0c444be commit 7c55b3d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
5 changes: 0 additions & 5 deletions src/main/java/sangpire/findup/LocalFile.java

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/sangpire/findup/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class Main {
public static void main(String[] args) {
File rootDir = new File("D:\\");
Worker worker = new Worker(rootDir);
worker.cleanUp();
Travler travler = new Travler();
travler.visit(rootDir);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,15 @@
import java.util.Collections;

/**
* 주석 추가.
* 파일을 모조리 찾아내는 폴더 여행자.
*/
public class Worker {
public class Travler {

File rootDir;

public Worker(File rootDir) {
this.rootDir = rootDir;
}

public void cleanUp() {
lookupDir(0, this.rootDir);
public void visit(File dir) {
visit(0, dir);
}

void lookupDir(Integer depth, File dir) {
void visit(Integer depth, File dir) {
if (depth > 1) {
return;
}
Expand All @@ -34,7 +28,7 @@ void lookupDir(Integer depth, File dir) {
String fileMetaInfos =String.format("%s%s - %s\n", margin, file.isDirectory() ? "d" : "-" , file.getAbsolutePath());
System.out.print(fileMetaInfos);
if (file.exists() && file.isDirectory()) {
lookupDir(depth + 1, file);
visit(depth + 1, file);
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/sangpire/findup/TravlerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package sangpire.findup;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.File;

public class TravlerTest {

@Before
public void setUp() throws Exception {
}

@After
public void tearDown() throws Exception {
}

@Test
public void lookupDir() throws Exception {
File rootDir = new File("D:\\");
Travler travler = new Travler();
travler.visit(rootDir);
}

}

0 comments on commit 7c55b3d

Please sign in to comment.