package org.jboss.as.test.shared;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URL;

/**
 * Shared fs utils for the test suite
 *
 * @author Stuart Douglas
 */
public class FileUtils {

    private FileUtils() {

    }

    public static String readFile(Class<?> testClass, String fileName) {
        final URL res = testClass.getResource(fileName);
        return readFile(res);
    }

    public static String readFile(URL url) {
        BufferedInputStream stream = null;
        try {
            stream = new BufferedInputStream(url.openStream());
            byte[] buff = new byte[1024];
            StringBuilder builder = new StringBuilder();
            int read = -1;
            while ((read = stream.read(buff)) != -1) {
                builder.append(new String(buff, 0, read));
            }
            return builder.toString();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if (stream != null) {
                try {
                    stream.close();
                } catch (IOException e) {
                    //ignore
                }
            }
        }
    }

}

@@ -83,84 +83,416 @@
 .io.
-IOException;%0Aimport java.net.URL;%0A%0A/**%0A * Shared fs utils for the test suite
+BufferedOutputStream;%0Aimport java.io.Closeable;%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream;%0Aimport java.net.URL;%0A%0A/**%0A * Shared fs utils for the test suite.%0A * %0A * Keep this class dependent only on JDK classes as it's packed to deployed WAR's.
 %0A *%0A
@@ -1519,7 +1519,1872 @@
   %7D%0A
-%0A%7D
+    %0A    %0A    %0A    public static File getFileOrCheckParentsIfNotFound( String baseStr, String path ) throws FileNotFoundException %7B%0A        //File f = new File( System.getProperty(%22jbossas.project.dir%22, %22../../..%22) );%0A        File base = new File( baseStr );%0A        if( ! base.exists() )%7B%0A            throw new FileNotFoundException( %22Base path not found: %22 + base.getPath() );%0A        %7D%0A        base = base.getAbsoluteFile();%0A        %0A        File f = new File( base, path );%0A        if ( f.exists() )%0A            return f;%0A        %0A        File fLast = f;%0A        while( ! f.exists() )%7B%0A            int slash = path.lastIndexOf( File.separatorChar );%0A            if( slash %3C= 0 )  // no slash or %22/xxx%22%0A                throw new FileNotFoundException(%22Path not found: %22 + f.getPath());%0A            path = path.substring( 0, slash );%0A            fLast = f;%0A            f = new File( base, path );%0A        %7D%0A        // When first existing is found, report the last non-existent.%0A        throw new FileNotFoundException(%22Path not found: %22 + fLast.getPath());%0A    %7D%0A%0A%0A    %0A    %0A    public static void copyFile(final File src, final File dest) throws Exception %7B%0A        final InputStream in = new BufferedInputStream(new FileInputStream(src));%0A        try %7B%0A            dest.getParentFile().mkdirs();%0A            final OutputStream out = new BufferedOutputStream(new FileOutputStream(dest));%0A            try %7B%0A                int i = in.read();%0A                while (i != -1) %7B%0A                    out.write(i);%0A                    i = in.read();%0A                %7D%0A            %7D finally %7B%0A                close(out);%0A            %7D%0A        %7D finally %7B%0A            close(in);%0A        %7D%0A    %7D%0A    %0A    %0A    public static void close(Closeable closeable) %7B%0A        try %7B%0A            closeable.close();%0A        %7D catch (IOException ignore) %7B%0A        %7D%0A    %7D%0A    %0A%0A%7D// class
 %0A

Add few methods to FileUtils