javarequirementstracer
Class FileUtils

java.lang.Object
  extended by javarequirementstracer.FileUtils

public final class FileUtils
extends java.lang.Object

Author:
Ronald Koster

Method Summary
static void assertNotPresent(java.lang.String content, int index1, int index2, java.lang.String... strings)
          Convenience method for testing.
static int assertPresent(java.lang.String content, int index1, int index2, java.lang.String... strings)
          Convenience method for testing.
static void copyStream(java.io.InputStream in, java.io.OutputStream out)
           
static boolean exists(java.lang.String filename)
           
static java.lang.String getAbsolutePath(java.lang.String filename)
           
static java.lang.String getCanonicalPath(java.lang.String filename)
           
static java.lang.String getParent(java.lang.String filename)
           
static boolean isAbsolute(java.lang.String filename)
           
static byte[] readFileAsBytes(java.io.File file)
           
static byte[] readFileAsBytes(java.lang.String filename)
           
static java.lang.String readFileAsString(java.io.File file)
           
static java.lang.String readFileAsString(java.lang.String filename)
           
static void writeFile(java.io.File file, byte[] bytes)
           
static void writeFile(java.io.File file, java.lang.String str)
           
static void writeFile(java.lang.String filename, byte[] bytes)
           
static void writeFile(java.lang.String filename, java.lang.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 java.lang.String readFileAsString(java.lang.String filename)

readFileAsString

public static java.lang.String readFileAsString(java.io.File file)

readFileAsBytes

public static byte[] readFileAsBytes(java.lang.String filename)

readFileAsBytes

public static byte[] readFileAsBytes(java.io.File file)

writeFile

public static void writeFile(java.lang.String filename,
                             java.lang.String str)

writeFile

public static void writeFile(java.io.File file,
                             java.lang.String str)

writeFile

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

writeFile

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

copyStream

public static void copyStream(java.io.InputStream in,
                              java.io.OutputStream out)

exists

public static boolean exists(java.lang.String filename)

getAbsolutePath

public static java.lang.String getAbsolutePath(java.lang.String filename)

getCanonicalPath

public static java.lang.String getCanonicalPath(java.lang.String filename)

isAbsolute

public static boolean isAbsolute(java.lang.String filename)

getParent

public static java.lang.String getParent(java.lang.String filename)

assertPresent

public static int assertPresent(java.lang.String content,
                                int index1,
                                int index2,
                                java.lang.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:
java.lang.IllegalArgumentException - if content does not contain any of the strings in the indicated substring.

assertNotPresent

public static void assertNotPresent(java.lang.String content,
                                    int index1,
                                    int index2,
                                    java.lang.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:
java.lang.IllegalArgumentException - if content does contain any of the strings in the indicated substring.


Copyright © 2010. All Rights Reserved.