package be.ephec.nsjc.jws.internal;

import java.io.File;
import java.nio.file.Files;

public class FileUtils {

    public static String baseDir = "www" + File.separator;

    /** For a filename given give the content
     * @param uri the relative path from the base dir
     * @return le content of the file
     */
    public static byte[] getFile(String uri) {
        return null;
    }

    /** Save on the disk a file at the uri given with the content
     * @param uri the relative path from the base dir
     * @param content the content of the file
     */
    public static void postFile(String uri, byte[] content) {

    }

    /** Check if the given uri is an existing file
     * @param uri the relative path from the base dir
     * @return wheter the file exists or not
     */
    public static boolean fileExists(String uri) {
        return true;
    }

}

@@ -51,16 +51,44 @@
 o.File;%0A
+import java.io.IOException;%0A
 import j
@@ -135,29 +135,30 @@
 ils %7B%0A%0A    p
-ublic
+rivate
  static Stri
@@ -179,26 +179,184 @@
 www%22
- + File.separator;
+;%0A    public static void setBaseDir(String baseDir) %7B%0A        FileUtils.baseDir = baseDir;%0A    %7D%0A    public static String getBaseDir() %7B%0A        return FileUtils.baseDir;%0A    %7D
 %0A%0A  
@@ -483,32 +483,81 @@
 ent of the file%0A
+     * @throws IOException if the reading failed%0A
      */%0A    publ
@@ -576,24 +576,31 @@
 te%5B%5D getFile
+Content
 (String uri)
@@ -604,29 +604,105 @@
 ri) 
-%7B%0A        return null
+throws IOException %7B%0A        File f = getFile(uri);%0A        return Files.readAllBytes(f.toPath())
 ;%0A  
@@ -868,24 +868,73 @@
 of the file%0A
+     * @throws IOException if the writing failed%0A
      */%0A    
@@ -993,253 +993,960 @@
 nt) 
-%7B%0A%0A    %7D%0A%0A    /** Check if the given uri is an existing file%0A     * @param uri the relative path from the base dir%0A     * @return wheter the file exists or not%0A     */%0A    public static boolean fileExists(String uri) %7B%0A        return true;%0A    %7D%0A
+throws IOException %7B%0A        File f = getFile(uri);%0A        Files.write(f.toPath(), content);%0A    %7D%0A%0A    /** Remove a file from the filesystem%0A     * @param uri the relative path from the base dir%0A     * @throws IOException if the delete failed%0A     */%0A    public static void deleteFile(String uri) throws IOException %7B%0A        File f = getFile(uri);%0A        Files.delete(f.toPath());%0A    %7D%0A%0A    /** Check if the given uri is an existing file%0A     * @param uri the relative path from the base dir%0A     * @return wheter the file exists or not%0A     */%0A    public static boolean fileExists(String uri) %7B%0A        File f = getFile(uri);%0A        return f.exists() && !f.isDirectory();%0A    %7D%0A%0A    /** Convert an URI to an OS path%0A     * @param uri the relative path fromthe base dir%0A     * @return the file at the given location%0A     */%0A    private static File getFile(String uri) %7B%0A        return new File(baseDir + uri.replaceAll(%22/%22, File.separator));%0A    %7D
 %0A%7D%0A

add deleteFile