This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
public class DaftarFile | |
{ | |
public static void main(String[] args) | |
{ | |
// Masukan path direktori disini | |
String path = "."; | |
String files; | |
File folder = new File(path); | |
File[] arrDaftarFile = folder.listFiles(); | |
for (int i = 0; i < arrDaftarFile.length; i++) | |
{ | |
if (arrDaftarFile[i].isFile()) | |
{ | |
files = arrDaftarFile[i].getName(); | |
/* Jika hanya ingin menampilkan ekstensi tertentu gunakan kode ini | |
if (files.endsWith(".txt") || files.endsWith(".TXT")) // Hanya tampilkan file dengan ekstensi TXT | |
{ | |
System.out.println(files); | |
} */ | |
System.out.println(files); | |
} | |
} | |
} | |
} |
No comments:
Post a Comment