Here you can find the source of executeLS()
public static String executeLS()
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static final String ROOT = "user.dir"; public static String executeLS() { // TODO Auto-generated method stub //ArrayList<String> fileNames = new ArrayList<String>(); StringBuilder directoryList = new StringBuilder(); try {/* w w w .jav a 2 s . c o m*/ File files = new File(executePWD()); File[] fList = files.listFiles(); for (File f : fList) directoryList.append(f.getName() + "\t"); //fileNames.add(f.getName()); } catch (Exception e) { System.out.println("----Exception in LS command execution -----" + e.getMessage()); } return directoryList.toString(); } public static String executePWD() { // TODO Auto-generated method stub String currentDirectory = null; try { currentDirectory = System.getProperty(ROOT); } catch (Exception e) { System.out.println("----Exception in PWD command execution -----" + e.getMessage()); } return currentDirectory; } }