package no3010; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Process pr = Runtime.getRuntime().exec("ls /bin -F"); Scanner sc = new Scanner(pr.getInputStream()); ArrayList lis = new ArrayList<>(); try { while(true) { if (sc.hasNext()) { String s = sc.next(); if (s.startsWith(".") || s.endsWith("/")) { continue; } lis.add(s); } } }catch (Exception e) { } Collections.sort(lis); for(String s: lis) { System.out.println(s); } } }