Skip to content

Instantly share code, notes, and snippets.

@mariiaKolokolova
Created June 2, 2020 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariiaKolokolova/f984fbf4660e894f4d43c2b29744528e to your computer and use it in GitHub Desktop.
Save mariiaKolokolova/f984fbf4660e894f4d43c2b29744528e to your computer and use it in GitHub Desktop.
import java.io.File;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Input folder:");
Scanner sc = new Scanner(System.in);
String folderName = sc.nextLine();
folderList(folderName);
sc.close();
}
static void folderList(String folderName) {
File folder = new File(folderName);
for (File file : folder.listFiles()) {
if (file.isDirectory()) {
System.out.println(file.getName());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment