javarequirementstracer
Class FileUtils

java.lang.Object
  extended by javarequirementstracer.FileUtils

public final class FileUtils
extends Object

Author:
Ronald Koster

Method Summary
static void assertNotPresent(String content, int index1, int index2, String... strings)
          Convenience method for testing.
static int assertPresent(String content, int index1, int index2, String... strings)
          Convenience method for testing.
static void copyFile(File src, File target)
           
static void copyStream(InputStream in, OutputStream out)
           
static boolean exists(String filename)
           
static String getAbsolutePath(String filename)
           
static String getCanonicalPath(String filename)
           
static String getParent(String filename)
           
static boolean isAbsolute(String filename)
           
static byte[] readFileAsBytes(File file)
           
static byte[] readFileAsBytes(String filename)
           
static String readFileAsString(File file)
           
static String readFileAsString(String filename)
           
static void writeFile(File file, byte[] bytes)
           
static void writeFile(File file, InputStream in)
           
static void writeFile(File file, String str)
           
static void writeFile(String filename, byte[] bytes)
           
static void writeFile(String filename, String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readFileAsString

public static String readFileAsString(String filename)

readFileAsString

public static String readFileAsString(File file)

readFileAsBytes

public static byte[] readFileAsBytes(String filename)

readFileAsBytes

public static byte[] readFileAsBytes(File file)

writeFile

public static void writeFile(String filename,
                             String str)

writeFile

public static void writeFile(File file,
                             String str)

writeFile

public static void writeFile(String filename,
                             byte[] bytes)

writeFile

public static void writeFile(File file,
                             byte[] bytes)

writeFile

public static void writeFile(File file,
                             InputStream in)

copyStream

public static void copyStream(InputStream in,
                              OutputStream out)

copyFile

public static void copyFile(File src,
                            File target)

exists

public static boolean exists(String filename)

getAbsolutePath

public static String getAbsolutePath(String filename)

getCanonicalPath

public static String getCanonicalPath(String filename)

isAbsolute

public static boolean isAbsolute(String filename)

getParent

public static String getParent(String filename)

assertPresent

public static int assertPresent(String content,
                                int index1,
                                int index2,
                                String... strings)
Convenience method for testing.

Parameters:
content - Piece of text to be scanned.
index1 - Index to scan from (inclusive).
index2 - Index to to scan unto (exclusive). If < 0 it is ignored.
strings - String that must be contained.
Returns:
Index of last string of strings.
Throws:
IllegalArgumentException - if content does not contain any of the strings in the indicated substring.

assertNotPresent

public static void assertNotPresent(String content,
                                    int index1,
                                    int index2,
                                    String... strings)
Convenience method for testing. Opposite of assertPresent(String, int, int, String...).

Parameters:
content - Idem as at #assertPresent(String, int, int, String...).
index1 - Idem.
index2 - Index to to scan unto (exclusive).
strings - String that must not be contained.
Throws:
IllegalArgumentException - if content does contain any of the strings in the indicated substring.


Copyright © 2010. All Rights Reserved.