package main.java.filemanager;

import java.io.File;
import javax.servlet.jsp.JspWriter;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by mac on 03/05/15.
 */
public class FileManager {
    public static List<DirItem> getDir(String dir) {
        File folder = new File(dir);
        File[] listOfFiles = folder.listFiles();

        List<DirItem> list = new ArrayList<DirItem>(listOfFiles.length);

        for (File file : listOfFiles) {
            DirItem item = new DirItem(file);
            list.add(item);
        }
        return list;
    }
    public static void getDirJson(JspWriter out, String dir) {
        //keep in list, so we can sort on arbitrary property
        List<DirItem> list = getDir(dir);
        out.println("Ahoj 1" );
        for (DirItem item : list) {
            out.println(item.getName() + "<br>");
        }
        out.println( "Ahoj 2" );
    }
}

@@ -61,25 +61,40 @@
 java
-x.servlet.jsp.Jsp
+.io.IOException;%0Aimport java.io.
 Writ
@@ -618,11 +618,8 @@
 son(
-Jsp
 Writ
@@ -630,32 +630,50 @@
 ut, String dir) 
+throws IOException
 %7B%0A        //keep
@@ -773,23 +773,21 @@
     out.
-println
+write
 (%22Ahoj 1
@@ -787,17 +787,16 @@
 %22Ahoj 1%22
- 
 );%0A     
@@ -842,23 +842,21 @@
     out.
-println
+write
 (item.ge
@@ -900,15 +900,13 @@
 out.
-println
+write
 ( %22A

test api.jsp