package no3010; import java.io.InputStream; 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"); InputStream is = pr.getInputStream(); StringBuilder sb = new StringBuilder(); ArrayList lis = new ArrayList<>(); try { while(true) { int c = is.read(); if (c < 0) { break; } sb.appendCodePoint(c); } }finally{ is.close(); } String input = sb.toString(); Scanner sc = new Scanner(input); while(sc.hasNext()) { String s = sc.next(); if (!s.startsWith(".") && !s.endsWith("/")) { lis.add(s); } } Collections.sort(lis); for(String s: lis) { System.out.println(s); } } }